home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 13
/
AACD13.ISO
/
AACD
/
Utilities
/
QuickFile
/
ARexx
/
Demo.quickfile
< prev
next >
Wrap
Text File
|
2000-05-27
|
5KB
|
177 lines
/*
$VER: Demo.quickfile 1.6 (27 May 2000 23:50:51) by M Andre Z Eckenrode
Demo ARexx script for QuickFile
Requires QuickFile v3.24 and the AddressBook example database, included in the
QuickFile archive.
*/
options results /* required to make result string available */
lf = d2c(10)
header = 'QuickFile v3.24 ARexx Script Demo'lf||copies('=',33)lf
setfile
db = result
if upper(db) ~== 'ADDRESSBOOK' then do
setfile 'AddressBook'
if rc = 5 then do
msg = header'This demo ARexx script requires that the AddressBook example'lf'database file be opened. Please open it and try again.'
reqmsg '"'msg'"'
exit
end
end
wintofront /* make sure user can see the window */
lib = 'rexxsupport.library'
if ~show('l',lib) then call addlib(lib,0,-30)
call delay(5)
/* Display a simple message in a requester */
reqchoice '"'header'Let''s load a LIST view..."'
if rc = 5 then exit
/* Load a new view and redraw display according to the view */
setview /* Obtain the current view name */
if upper(result) ~== 'ADDRLIST.VIEW' then do /* Is it already current */
setview 'AddrList.view'
if rc = 5 then do /* Not found - try loading it */
loadview 'AddrList.view'
if rc > 0 then call errorproc('Error loading AddrList.view')
setview 'AddrList.view'
end
end
reqmsg '"Few database programs have a good list display."'
/*
Simple search of the database. The matching records are placed in an index
named 'Selected' The 'refresh' command causes an immediate redraw of the
display. Without it, the display is not updated until the macro finishes
*/
reqmsg '"Now let''s find all the ''Smiths'' using ''SOUNDS LIKE''..."'
newsearch 'Lastname' sounds 'smith' /* set search criteria */
dosearch /* find all the records */
numfound = result /* returns number found */
refresh
/* sends reqmsg 'We found x Smiths' to QuickFile */
reqmsg '"We found' numfound 'names that sound like ''Smith''."'
reqmsg '"Now a sort by ''COUNTRY'' and ''NAME''..."'
setindex 'name' /* swap back to a full list */
sort 'country' a 'lastname' a 'firstname' a
refresh /* and show the result */
reqmsg '"Here is the sorted list..."'
/* Now lets do some printing */
reqmsg '"This counts records by country - full report..."'
numrecs /* get number of records in index */
soi = -1*(result)
next '"'soi'"' /* goes to top of index; quotes required because sof is negative */
report '-1' screen '"This title inserted from ARexx"'
/* Select Summary only view and print report */
reqmsg '"Now a count by country using the ''Summary Only'' option..."'
view = 'SummOnly.view'
call viewreport
/* Field wrap example */
reqmsg '"And now for field wrapping..."'
view = 'FieldWrap.view'
call viewreport
/* Label print example */
setindex 'name'
numrecs
soi = -1*(result)
reqmsg '"Now some address labels..."'
view = 'AddrLabels.view'
call viewreport
/* Show off choice, string and field requesters */
reqchoice '"Here''s a fine choice requester.'lf'Press a button...."'
if rc = 5 then reqmsg '"You selected ''Cancel'' (or pressed ESC)"'
else reqmsg '"You selected ''OK'' (or pressed RETURN)"'
reqstring '"...with a default string in it!" "And a fine string requester..."'
if rc = 0 then reqmsg '"Your string was'lf'\034'result'\034"'
msg = 'You should use ''\\034'' for double-quote marks and ''\\039'' for'
msg.1 = 'single-quote marks in strings that are being passed to'
msg.2 = 'QuickFile commands, since actual quote marks may be'
msg.3 = 'interpreted incorrectly and result in your string being'
msg.4 = 'truncated. Use ''\\\xxx'' for a literal backslash and digits.'
do i = 1 to 4
msg = msg||lf||msg.i
end
reqmsg '"'msg'"'
reqmsg '"Select a field from the following field requester..."'
reqfield
if rc = 0 then do
fld = upper(result)
reqmsg '"The field you selected was '''fld'''."'
getfield '"'fld'"'
val = result
reqmsg '"The value of '''fld''' in the current record is '''val'''."'
query field fld1 '"'fld'"'
reqmsg '"'''fld''' is a' upper(fld1.type) 'field with a maximum length of' fld1.length'."'
end
else reqmsg '"You pressed '''CANCEL'''"'
query field fld1
query index ndx1
reqmsg '"'''AddressBook''' has a total of' fld1.0 'field(s) and' ndx1.0 'index(es)."'
query file 'DB'
msg = 'The following QuickFile databases/windows are open:'lf
do i = 1 to db.0
if db.i == '' then db.i = '<Empty window>'
msg = msg||lf||db.i
end
reqmsg '"'msg'"'
/* Open and close windows */
openwin
reqmsg '"Behold! A new window, for another file! Now you see it..."'
closewin
reqmsg '"...Now you don''t!"'
/* Finished */
reqmsg '"This concludes your tour of QuickFile''s'lf' ARexx capabilities. Come again soon."'
exit
errorproc:
arg msg
reqmsg '"'msg'"'
exit
viewreport:
next '"'sof'"'
setview '"'view'"'
if rc = 5 then do
loadview '"'view'"'
if rc > 0 then call errorproc('Error loading' view)
setview '"'view'"'
end
report '-1' screen
return