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

  1. * Viewedit.prg allows viewing and editing of records in
  2. * Customer.dbf
  3.  
  4. * Select database Customer with index Lastname
  5. SELECT Customer
  6. SET INDEX TO Lastname, Custno, Ziplist
  7.  
  8. * Begin main control loop
  9. STORE .T. TO more
  10. DO WHILE more
  11.     CLEAR
  12.     @  3,0  SAY CENTER("VIEW/EDIT CUSTOMER RECORDS")
  13.  
  14.     * Do until a record that exists is specified
  15.     STORE .T. TO badinput
  16.     DO WHILE badinput
  17.  
  18.        * Get last name or company of customer
  19.        STORE SPACE(25) TO findcust
  20.        @ 11,5  SAY "Enter customer's last name or company: ";
  21.        GET findcust
  22.        READ
  23.  
  24.        * Search for a last name that is the same as findcust
  25.        SEEK UPPER(findcust)
  26.  
  27.        * If indexed search not successful, do sequential search for
  28.        * Company = findcust
  29.        IF .NOT. FOUND()
  30.        LOCATE FOR Company = findcust
  31.  
  32.        * If both searches are unsuccessful, inform user
  33.        IF .NOT. FOUND()
  34.            STORE " " TO again
  35.            @ 13,5  SAY "No such record found.  Try again? "+;
  36.            "(Y/N): " GET again PICTURE "!"
  37.            READ
  38.  
  39.            * If user does not want to try again, reset loop
  40.            * conditions to exit program
  41.            IF again = "N"
  42.            STORE .F. TO badinput, more
  43.            ENDIF
  44.  
  45.        * If sequential search successful, reset badinput to
  46.        * exit this loop
  47.        ELSE
  48.            STORE .F. TO badinput
  49.        ENDIF
  50.  
  51.        * If indexed search successful, reset badinput to exit this
  52.        * loop
  53.        ELSE
  54.        STORE .F. to badinput
  55.        ENDIF
  56.  
  57.     * End of while badinput loop
  58.     ENDDO
  59.  
  60.     * If more is still true, then continue; more is only set to
  61.     * false if both searches are unsuccessful
  62.     IF more
  63.  
  64.        * Store contents of current record to automem memory
  65.        * variables
  66.        STORE AUTOMEM
  67.  
  68.        * Display record using format Custform
  69.        SET FORMAT TO Custform
  70.        READ
  71.        CLOSE FORMAT
  72.  
  73.        * Save any changes made to record
  74.        REPLACE AUTOMEM
  75.  
  76.        * Display/edit additional records?
  77.        STORE " " TO morerecs
  78.        @ 22,0
  79.        @ 22,5  SAY "Edit/View additional records? (Y/N): ";
  80.        GET morerecs PICTURE "!"
  81.        READ
  82.        IF morerecs = "N"
  83.        STORE .F. TO more
  84.        ENDIF
  85.     ENDIF
  86. ENDDO
  87. CLEAR AUTOMEM
  88. RETURN
  89.