home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / CLIPB52.ZIP / MARTIN.ZIP / EXAMPL02.PRG < prev    next >
Encoding:
Text File  |  1989-06-01  |  1.0 KB  |  49 lines

  1. ********************************
  2. * EXAMPL02.PRG                 *
  3. * Written By Gregory A. Martin *
  4. ********************************
  5.  
  6. * This example illustrates the fundementals of using G_RLOCK() and G_FLOCK().
  7.  
  8. DO Startup
  9.  
  10. * Open the two needed databases
  11. IF .not. G_Use("ARec", "ARec1, ARec2", "Receive", .f., .f.)
  12.   * If unable to open then return
  13.   RETURN
  14. ENDIF
  15. IF .not. G_Use("APay", "APay1, APay2", "Payable", .f., .f.)
  16.   * If unable to open then close first database and return
  17.   SELECT Receive
  18.   USE
  19.   RETURN
  20. ENDIF
  21.  
  22. * ... Get some user input ...
  23.  
  24. SELECT Receive
  25. SEEK Account1
  26. * If record not found than append a blank, else lock found record.
  27. IF G_RLOCK(.not. FOUND())
  28.   REPLACE Receive->AccNum  WITH m->Account1
  29.   REPLACE Receive->AccName WITH m->Name1
  30.   UNLOCK
  31. ELSE
  32.   ErrorBox("Account Not Updated!")
  33. ENDIF
  34.  
  35. SELECT Payable
  36. * Try forever (if needed) to lock file so that it can be SUMmed.
  37. G_FLOCK("FOREVER")
  38. SUM AccAmount TO Total
  39. UNLOCK
  40.  
  41. * Close databases and return
  42. SELECT Receive
  43. USE
  44. SELECT Payable
  45. USE
  46. RETURN
  47.  
  48.  
  49.