home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / sri314_b.zip / DEMOPRGS.ZIP / MEMBERS.PRG < prev    next >
Text File  |  1990-10-03  |  4KB  |  139 lines

  1. *** MEMBERS.PRG **
  2. **  (C) Copyright 1990, Sub Rosa Publishing Inc.
  3. **  A demonstration program provided SR-Info users.
  4. **  This program may be copied freely. If it is used in commercial code,
  5. **  please credit the source, Sub Rosa Publishing Inc.
  6. **
  7. **  MEMBERS is compatible with all current versions of VP-Info and  SR-Info
  8. **  This short program offers most of the functionality required for basic
  9. **  list management. Add provisions to delete records and print reports
  10. **  and you have a full-blown application.
  11. **
  12. **  MEMBERS demonstrates a simple transaction mode approach to record
  13. **  maintenance. All 'scratch pad' work is done in the temporary file.
  14. **  The master file is only updated after confidence in the new record
  15. **  is established.
  16. **
  17. **  Note the heavy use of the SELECT command to force SR-Info to work on
  18. **  the intended file. New SR-Info users often go wrong by ending up
  19. **  in the wrong SELECT area, forgetting that the compiler assumes
  20. **  a SELECT error without knowing which branch of the code execution
  21. **  will follow. Therefore it is a good precaution to specify the
  22. **  SELECT area explicitly.
  23. **
  24. **  Bernie Melman and Sid Bursten
  25. **
  26. *
  27. USE#1 members index members
  28. USE#2 membtemp ; same structure as members but contains only one record
  29. IF :color <> 7
  30.    SET color to 117; violet on grey (for variety!?)
  31. ENDIF
  32.  
  33. DO WHILE t; put main menu in an infinite loop
  34.    COLOR :color,0,0,24,79,177; fill screen with pattern
  35. * 177 is a shaded fill character.
  36.    WINDOW 6,18,19,62 double; declare space for menu text
  37.    MODE = '?'
  38.    ERASE; fills window with blanks
  39.    TEXT
  40.  
  41.           MEMBERS MAIN MENU
  42.  
  43.      0. Exit program and SR-Info.
  44.  
  45.      1. Choose a starting record.
  46.      2. Browse master file.
  47.      3. Edit copy of current record.
  48.      4. Make changes permanent.
  49.      5. Move changes to new record.
  50.      6. Edit new record.
  51.      7. Exit program - stay in SR-Info.
  52.  
  53.    ENDTEXT
  54.    CURSOR 12,26 ; positions menu cursor over 1st character of 1st choice
  55.    SELECTION = menu(7,33); seven choices (including 0) bar width 33
  56.    DO CASE
  57.    CASE selection=0
  58.       QUIT
  59.    CASE selection=1 ; choose starting record
  60.       SELECT 1
  61.       PERFORM start_rec
  62.       @ 21,19 say "Press Pge Up and Pge Down Keys to change record"
  63.       @ 22,19 say "Press End key to return to Main Menu           " 
  64.       BROWSE
  65.    CASE selection=2 ; browse master file
  66.       SELECT 1
  67.       BROWSE
  68.    CASE selection=3 ; edit copy of current record
  69.       WINDOW
  70.       SELECT 1
  71.       PERFORM over2
  72.       SELECT 2
  73.       EDIT
  74.    CASE selection=4 ; update master file
  75.       SELECT 2
  76.       PERFORM over1
  77.       SELECT 1
  78.    CASE selection=5 ; new record to master file
  79.       SELECT 2
  80.       APPEND to 1
  81.    CASE selection=6 ; blank record in temp file
  82. * note: This part of the demo must be 'fleshed out' for serious work
  83. *       As presented it is up to the user to go back to the main menu
  84. *       and select 5 to append to master file. Selecting 4 will
  85. *       overwrite an active record. End users should be handled more gently!
  86.       SELECT 2
  87.       ZAP
  88.       APPEND blank
  89.       FLUSH
  90.       WINDOW
  91.       EDIT
  92.    CASE selection=7
  93.       WINDOW; reset window to full screen
  94.       ERASE
  95.       CANCEL
  96.    ENDCASE
  97.    WINDOW 2,20
  98. ENDDO
  99. **** END OF MEMBERS.PRG main program module
  100. PROCEDURE start_rec
  101.    CLEAR gets
  102.    mkey=blank(10)
  103.    ERASE
  104.    TEXT
  105. ENTER ESTIMATE OF LAST NAME -
  106.   up to 10 characters
  107.  LAST NAME: @mkey
  108.    ENDTEXT
  109.    READ
  110.    MKEY = !(trim(mkey)) ; get rid of trailing blanks
  111.    FIND &mkey
  112.    IF #=0 ; no find - so go to next record
  113.       GOTO :near
  114.    ENDIF
  115. ENDPROCEDURE; start_rec
  116. PROCEDURE over1
  117.    REPLACE cust_no#1    with cust_no#2
  118.    REPLACE lname#1      with lname#2
  119.    REPLACE fname#1      with fname#2
  120.    REPLACE street#1     with street#2
  121.    REPLACE city#1       with city#2
  122.    REPLACE state#1      with state#2
  123.    REPLACE zip#1        with zip#2
  124.    REPLACE home_phone#1 with home_phone#2
  125.    REPLACE work_phone#1 with work_phone#2
  126. ENDPROCEDURE; over1
  127. PROCEDURE over2
  128.    REPLACE cust_no#2    with cust_no#1
  129.    REPLACE lname#2      with lname#1
  130.    REPLACE fname#2      with fname#1
  131.    REPLACE street#2     with street#1
  132.    REPLACE city#2       with city#1
  133.    REPLACE state#2      with state#1
  134.    REPLACE zip#2        with zip#1
  135.    REPLACE home_phone#2 with home_phone#1
  136.    REPLACE work_phone#2 with work_phone#1
  137. ENDPROCEDURE; over2
  138. ** end of MEMBERS.PRG **
  139.