home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a004 / 4.ddi / TUTORIAL / ADDCUST.PRG next >
Encoding:
Text File  |  1988-01-17  |  1.3 KB  |  56 lines

  1. * Addcust.prg adds a new customer record to Customer.dbf
  2. SELECT Customer
  3. SET INDEX TO Lastname, Custno, Ziplist
  4.  
  5. * Get customer number (cnomem) from memory file Cnostore
  6. * or initialize customer number to 5
  7. IF FILE("Cnostore.mem")
  8.     RESTORE FROM Cnostore ADDITIVE
  9. ELSE
  10.     STORE 5 TO cnomem
  11. ENDIF
  12.  
  13. * Begin main loop
  14. STORE .T. TO more
  15. DO WHILE more
  16.  
  17.     * Calculate customer number of new record
  18.     STORE cnomem + 1 TO cnomem
  19.     STORE STR(cnomem,5) TO custno
  20.     * Store default values of contacted and country
  21.     STORE DATE() TO contacted
  22.     STORE "U.S.A." TO country
  23.  
  24.     * Add a new blank record to end of Customer
  25.     APPEND BLANK
  26.  
  27.     * Get new record contents, store in automem variables
  28.     SET FORMAT TO Custform
  29.     READ
  30.     CLOSE FORMAT
  31.  
  32.     * Place memory variable values in new record
  33.     REPLACE AUTOMEM
  34.  
  35.     * Check whether additional records are to be entered
  36.     STORE " " TO addition
  37.     @ 22,0
  38.     @ 22,5 SAY "Enter additional records? (Y/N): ";
  39.     GET addition PICTURE "Y"
  40.     READ
  41.     IF addition = "N"
  42.     STORE .F. TO more
  43.     ENDIF
  44.  
  45.     * Initialize automem variables
  46.     CLEAR AUTOMEM
  47.  
  48. * End of main loop
  49. ENDDO
  50.  
  51. * Store new value of cnomem
  52. SAVE TO Cnostore ALL LIKE cnomem
  53.  
  54. * Return to Menu.prg
  55. RETURN
  56.