home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Utilities / QuickFile / ARexx / Demo.quickfile < prev    next >
Text File  |  2000-05-27  |  5KB  |  177 lines

  1. /*
  2. $VER: Demo.quickfile 1.6 (27 May 2000  23:50:51) by M Andre Z Eckenrode
  3.  
  4. Demo ARexx script for QuickFile
  5.  
  6. Requires QuickFile v3.24 and the AddressBook example database, included in the
  7. QuickFile archive.
  8. */
  9.  
  10. options results /* required to make result string available */
  11.  
  12. lf = d2c(10)
  13. header = 'QuickFile v3.24 ARexx Script Demo'lf||copies('=',33)lf
  14.  
  15. setfile
  16. db = result
  17. if upper(db) ~== 'ADDRESSBOOK' then do
  18.     setfile 'AddressBook'
  19.     if rc = 5 then do
  20.         msg = header'This demo ARexx script requires that the AddressBook example'lf'database file be opened. Please open it and try again.'
  21.         reqmsg '"'msg'"'
  22.         exit
  23.     end
  24. end
  25.  
  26. wintofront /* make sure user can see the window */
  27.  
  28. lib = 'rexxsupport.library'
  29. if ~show('l',lib) then call addlib(lib,0,-30)
  30. call delay(5)
  31.  
  32. /* Display a simple message in a requester */
  33.  
  34. reqchoice '"'header'Let''s load a LIST view..."'
  35. if rc = 5 then exit
  36.  
  37. /* Load a new view and redraw display according to the view */
  38.  
  39. setview /* Obtain the current view name */
  40. if upper(result) ~== 'ADDRLIST.VIEW' then do  /* Is it already current */
  41.     setview 'AddrList.view'
  42.     if rc = 5 then do  /* Not found - try loading it */
  43.         loadview 'AddrList.view'
  44.         if rc > 0 then call errorproc('Error loading AddrList.view')
  45.         setview 'AddrList.view'
  46.     end
  47. end
  48.  
  49. reqmsg '"Few database programs have a good list display."'
  50.  
  51. /*
  52. Simple search of the database. The matching records are placed in an index
  53. named 'Selected' The 'refresh' command causes an immediate redraw of the
  54. display. Without it, the display is not updated until the macro finishes
  55. */
  56.  
  57. reqmsg '"Now let''s find all the ''Smiths'' using ''SOUNDS LIKE''..."'
  58.  
  59. newsearch 'Lastname' sounds 'smith'        /* set search criteria  */
  60. dosearch                                   /* find all the records */
  61. numfound = result                          /* returns number found */
  62. refresh
  63.  
  64. /* sends reqmsg 'We found x Smiths' to QuickFile */
  65.  
  66. reqmsg '"We found' numfound 'names that sound like ''Smith''."'
  67.  
  68. reqmsg '"Now a sort by ''COUNTRY'' and ''NAME''..."'
  69. setindex 'name'             /* swap back to a full list */
  70. sort 'country' a 'lastname' a 'firstname' a
  71. refresh                     /* and show the result */
  72. reqmsg '"Here is the sorted list..."'
  73.  
  74. /* Now lets do some printing */
  75.  
  76. reqmsg '"This counts records by country - full report..."'
  77.  
  78. numrecs /* get number of records in index */
  79. soi = -1*(result)
  80. next '"'soi'"' /* goes to top of index; quotes required because sof is negative */
  81.  
  82. report '-1' screen '"This title inserted from ARexx"'
  83.  
  84. /* Select Summary only view and print report */
  85.  
  86. reqmsg '"Now a count by country using the ''Summary Only'' option..."'
  87. view = 'SummOnly.view'
  88. call viewreport
  89.  
  90. /* Field wrap example */
  91.  
  92. reqmsg '"And now for field wrapping..."'
  93. view = 'FieldWrap.view'
  94. call viewreport
  95.  
  96. /* Label print example */
  97.  
  98. setindex 'name'
  99. numrecs
  100. soi = -1*(result)
  101.  
  102. reqmsg '"Now some address labels..."'
  103. view = 'AddrLabels.view'
  104. call viewreport
  105.  
  106. /* Show off choice, string and field requesters */
  107.  
  108. reqchoice '"Here''s a fine choice requester.'lf'Press a button...."'
  109. if rc = 5 then reqmsg '"You selected ''Cancel'' (or pressed ESC)"'
  110. else reqmsg '"You selected ''OK'' (or pressed RETURN)"'
  111.  
  112. reqstring '"...with a default string in it!" "And a fine string requester..."'
  113. if rc = 0 then reqmsg '"Your string was'lf'\034'result'\034"'
  114.  
  115. msg = 'You should use ''\\034'' for double-quote marks and ''\\039'' for'
  116. msg.1 = 'single-quote marks in strings that are being passed to'
  117. msg.2 = 'QuickFile commands, since actual quote marks may be'
  118. msg.3 = 'interpreted incorrectly and result in your string being'
  119. msg.4 = 'truncated. Use ''\\\xxx'' for a literal backslash and digits.'
  120. do i = 1 to 4
  121.     msg = msg||lf||msg.i
  122. end
  123. reqmsg '"'msg'"'
  124.  
  125. reqmsg '"Select a field from the following field requester..."'
  126. reqfield
  127. if rc = 0 then do
  128.     fld = upper(result)
  129.     reqmsg '"The field you selected was '''fld'''."'
  130.     getfield '"'fld'"'
  131.     val = result
  132.     reqmsg '"The value of '''fld''' in the current record is '''val'''."'
  133.     query field fld1 '"'fld'"'
  134.     reqmsg '"'''fld''' is a' upper(fld1.type) 'field with a maximum length of' fld1.length'."'
  135. end
  136. else reqmsg '"You pressed '''CANCEL'''"'
  137.  
  138. query field fld1
  139. query index ndx1
  140. reqmsg '"'''AddressBook''' has a total of' fld1.0 'field(s) and' ndx1.0 'index(es)."'
  141.  
  142. query file 'DB'
  143. msg = 'The following QuickFile databases/windows are open:'lf
  144. do i = 1 to db.0
  145.     if db.i == '' then db.i = '<Empty window>'
  146.     msg = msg||lf||db.i
  147. end
  148. reqmsg '"'msg'"'
  149.  
  150. /* Open and close windows */
  151.  
  152. openwin
  153. reqmsg '"Behold! A new window, for another file! Now you see it..."'
  154. closewin
  155. reqmsg '"...Now you don''t!"'
  156.  
  157. /* Finished */
  158.  
  159. reqmsg '"This concludes your tour of QuickFile''s'lf' ARexx capabilities. Come again soon."'
  160. exit
  161.  
  162. errorproc:
  163.     arg msg
  164.     reqmsg '"'msg'"'
  165. exit
  166.  
  167. viewreport:
  168.     next '"'sof'"'
  169.     setview '"'view'"'
  170.     if rc = 5 then do
  171.         loadview '"'view'"'
  172.         if rc > 0 then call errorproc('Error loading' view)
  173.         setview '"'view'"'
  174.     end
  175.     report '-1' screen
  176. return
  177.