This script does much of this work automatically, by stepping through the database, pulling out records that match a specified criteria and copying certain of the fields into a text file, formatting them as it does so. It is set up to work with a software titles database and with Apple's Scriptable Text Editor, but with a little work you could probably customise it for any database and scriptable word processor or DTP program.
---get number of records with transaction tell application "FileMaker Pro" set numrec to Count Record of Database "Software.FM" ---number of records in database end tell end transaction ---setup output document tell application "Scriptable Text Editor" close every window ---in case already open, to avoid it writing in wrong window make document ---create document for output set font of text of document 1 to "Times" ---or whatever your favorite font is end tell ---initialise counters set RecPoint to 1 set tCount to 0 ---counter of number of extracted records ---main loop repeat while RecPoint <= numrec ---step through entire database [IMPORTANT NOTE - the comparison operator <= is an HTML approximation to the operator in the program, the less than or equal to operator, which in AppleScript is a single character that does not exist in ASCII or HTML] set tName to "" ---used to tell if we want this record with transaction tell application "FileMaker Pro" tell Record RecPoint of Database "Software.FM" ---do we want this record ? ---insert your own criteria for extracting recirds at this point ---delete the 'if...then' and 'end if' if want all records if Cell 8 contains "Consumer" and Cell 9 contains "Games" then ---extract information wanted from this record set tName to Cell 1 set tDesc to Cell 2 set tPubl to Cell 3 set tPrice to Cell 13 set tCount to tCount + 1 ---increase extracted records counter end if end tell end tell end transaction if tName "" then ---is this one we want ? tell document 1 of application "Scriptable Text Editor" ---copy & format information copy return & return & tName to end of it ---blank line and name of record set style of last paragraph to bold ---make this bold copy return & tDesc to end of it ---copy next field set style of last paragraph to plain ---format this as plain copy return & tPubl & " US$" & tPrice to end of it ---combine first two fields on one line set style of last paragraph to italic end tell end if set RecPoint to RecPoint + 1 ---increment loop counter end repeat ---put number extracted at top of file tell document 1 of "Scriptable Text Editor" copy tCount & " Titles" & return to beginning of it set style of first paragraph of it to bold set size of first paragraph of it to 14 end tell
© John Blackburne, johnb@hk.super.net, 17th March 1996