home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #3 / amigamamagazinepolishissue1998.iso / bazy / quickfile3 / arexx / demo.rexx < prev    next >
OS/2 REXX Batch file  |  1996-04-23  |  4KB  |  166 lines

  1. /*
  2.     Demo ARexx script for QuickFile
  3.  
  4.     Author: Alan Wigginton
  5.     Date:   21 March 1995
  6. */
  7.  
  8. options results     /* required to make result string available */
  9.  
  10. if ~open("con","CON:20/10/400/100/ARexx/CLOSE","W") then
  11.     exit 20
  12.  
  13. call writeln("con", "QuickFile ARexx script demo")
  14. call writeln("con", "This requires that QuickFile be running with")
  15. call writeln("con", "the demo AddressBook file open. If necessary")
  16. call writeln("con", "open the file NOW")
  17. call writeln("con", "Enter y to continue, anything else to end")
  18. if upper(readln("con")) ~= "Y" then
  19.     exit
  20.  
  21. if ~show(ports,"QUICKFILE.01") then
  22.     call ErrorProc "QuickFile.01 port not found"
  23.  
  24. address "QUICKFILE.01"
  25.  
  26. "setfile AddressBook"
  27. "wintofront"        /* make sure user can see the window */
  28.  
  29. /*
  30.     Display a simple message in a requester
  31.     --------------------------------------
  32. */
  33.  
  34. "reqmsg 'OK - Lets load a list style view'"
  35.  
  36. /*
  37.     Load a new view and redraw display according to the view
  38.     --------------------------------------------------------
  39. */
  40.  
  41. "setview"                           /* Obtain the current view name */
  42. if result ~= "AddrList.view" then   /* Is it already current        */
  43. do
  44.     "setview AddrList.view"
  45.     if rc = 5 then            /* Not found - try loading it   */
  46.     do
  47.     "loadview AddrList.view"
  48.     if rc > 0 then
  49.         call ErrorProc "Error loading AddrList.view"
  50.     "setview AddrList.view"
  51.     end
  52. end
  53.  
  54. "reqmsg 'Few database programs have a good list display'"
  55.  
  56. /*
  57.     Here is a simple search of the database. The matching records
  58.     are placed in an index named 'Selected'
  59.     The 'refresh' command causes an immediate redraw of the display.
  60.     Without it, the display is not updated until the macro finishes
  61. */
  62.  
  63. "reqmsg 'Now lets find all the Smiths using sounds like'"
  64.  
  65. "newsearch Lastname sounds smith"       /* set search criteria  */
  66. "dosearch"                              /* find all the records */
  67. numfound   = result            /* returns number found */
  68. "setindex selected"                     /* Use the selected index */
  69. "refresh"
  70.  
  71. /* sends reqmsg 'We found x Smiths' to QuickFile */
  72. /* quotes can be tricky         */
  73.  
  74. "reqmsg 'We found" numfound "names that sound like Smith'"
  75.  
  76. "reqmsg 'Now a sort over country and name'"
  77. "setindex name"             /* swap back to a full list */
  78. "sort country a lastname a firstname a"
  79. "refresh"                   /* and show the result  */
  80. "reqmsg 'Here is the sorted list'"
  81.  
  82. /*
  83.     Now lets do some printing
  84.     -------------------------
  85.  
  86.     next -9999 goes to top of file
  87. */
  88.  
  89. "reqmsg 'This counts records by country - full report'"
  90. "next -9999"
  91. "report -1 screen 'This title inserted from ARexx'"
  92.  
  93. /*
  94.     Select Summary only view and print report
  95. */
  96.  
  97. "next -9999"
  98. "reqmsg 'Now a Count by country using Summary Only option'"
  99. "setview SummOnly.view"
  100. if rc = 5 then
  101. do
  102.     "loadview SummOnly.view"
  103.     if rc > 0 then
  104.     call ErrorProc "Error loading SummOnly.view"
  105.     "setview SummOnly.view"
  106. end
  107. "report -1 screen"
  108.  
  109. /*
  110.     Field wrap example
  111. */
  112.  
  113. "next -9999"
  114. "reqmsg 'and now for field wrapping'"
  115. "setview FieldWrap.view"
  116. if rc = 5 then
  117. do
  118.     "loadview FieldWrap.view"
  119.     if rc > 0 then
  120.     call ErrorProc "Error loading FieldWrap.view"
  121.     "setview FieldWrap.view"
  122. end
  123.  
  124. "report -1 screen"
  125.  
  126. /*
  127.     Label print example
  128. */
  129.  
  130. "setindex name"
  131.  
  132. "reqmsg 'Now some address labels'"
  133. "setview AddrLabels.view"
  134. if rc = 5 then
  135. do
  136.     "loadview AddrLabels.view"
  137.     if rc > 0 then
  138.     call ErrorProc "Error loading AddrLabels.view"
  139.     "setview AddrLabels.view"
  140. end
  141.  
  142.  
  143. "next -9999"
  144. "report -1 screen"
  145.  
  146. "reqchoice 'This is a choice requester' 'Press a button'"
  147. if rc = 5 then
  148.     "reqmsg 'You chose Cancel (or pressed ESC)'"
  149. else
  150.     "reqmsg 'You chose OK (or pressed RETURN)'"
  151.  
  152. "reqmsg 'Thats all. I hope you like it'"
  153. exit
  154.  
  155. ErrorProc:
  156.  
  157. arg msg
  158.  
  159. call writeln("con", msg)
  160. call writeln("con", "Press return to continue")
  161. call readln("con")
  162. exit
  163.  
  164.  
  165.  
  166.