I have a fairly kludgy AppleScript that I’ve used for years to step through a value list and perform a fairly simple FM Pro script for each item. It always worked fine in OS 9/FM Pro 5, but it no longer works in OS X/FM Pro 6. I just run this from the ScriptEditor rather than a standalone, and I just use Tex-Edit for errors. Like I said, not pretty or fancy.
Basically, the AppleScript starts fine and FM does the first item, but it’s almost like FM Pro never returns control to the AppleScript. I have a time out for errors that’s always been there, and during the wait state, if I switch to Script Editor and then back to FM, it works. (!) When I do that, the Event Log in ScriptEditor reports “event <>” but I’m not sure what to do with that… If I simply leave the AppleScript unattended, the error handler times out, errors out that item in the AppleScript list, and continues with the next, resulting in every other item in my list not working.
Thanks in advance for any help, sorry for the not very technical description.
Bob
Here’s the AppleScript, with the FM Pro script below that:
set theList to {"about", "50", "different", "items"}
repeat with theItem in theList
try
tell application "FileMaker Pro"
with timeout of 120 seconds
try
activate
go to window "Line Items_.fp5"
--this stuff is necessary to have only one record in the found set. Otherwise setting the global takes forever.
delete every request
create request
set cell "Invoice#" of request 1 to "97-50002"
find
set field "gProducer" to theItem
do script FileMaker script "Automated Producer Royalty Detail"
on error errorCode
beep
tell application "Tex-Edit Plus"
set fileName to "Macintosh HD:Desktop Folder:" & (time of (current date) as string)
make new window
set selection to "Automated Producer Royalty Detail script had an error while processing " & (theItem as string) & ". " & (errorCode as string) & " " & (current date) & (ASCII character 13) & (ASCII character 13)
save window 1 in file fileName as string with creator «class TBB6»
end tell
end try
end timeout
end tell
on error
beep 3
end try
end repeat
FileMaker Pro script:
Enter Browse Mode
Go to Layout [ Sales Info ]
# “Restore find requests, so that the Omit $0 request is included.”
Enter Find Mode [ Request 1: Line Items to Products Relationship::Producer Artifact; Request 2 (Omit): New Extension =0 ]
[ Restore find requests ]
Go to Record/Request/Page
[ First ]
Insert Calculated Result [ Date, gDateRange ]
[ Select entire contents ]
Insert Calculated Result [ Line Items to Products Relationship::Producer, gProducer ]
[ Select entire contents ]
# “This script works fine unless there are no records for a producer, in which case the errorcapture should take over.”
Set Error Capture [ On ]
Perform Find
[ Replace Found Set ]
If [ Status(CurrentError) = 401 ]
If [ Status(CurrentFoundCount) = 0 ]
Enter Find Mode
Insert Text [ Invoice#, “97-50002” ]
[ Select entire contents ]
Perform Find
[ Replace Found Set ]
Go to Layout [ Royalty Detail (No Sales) ]
Print
[ No dialog ]
Set Error Capture [ Off ]
Go to Layout [ Sales Info ]
Enter Browse Mode
Exit Script
Else
# “else the Error is stuck but there are items found, so just exit the if loop and continue the script.”
Set Error Capture [ Off ]
End If
End If
Set Error Capture [ Off ]
# “ Sort by Product ID, for sub-summaries”
Freeze Window
Go to Layout [ Royalty Detail Producer Copy ]
Page Setup
[ Restore setup options, No dialog ]
Sort [ Sort Order: Product ID (Ascending) ]
[ Restore sort order, No dialog ]
# “two print commands so they're collated”
Print
[ No dialog ]
Print
[ No dialog ]
Enter Browse Mode
Go to Layout [ Sales Info ]