Re: Script Timer/Filemaker question
Re: Script Timer/Filemaker question
- Subject: Re: Script Timer/Filemaker question
- From: "Gary (Lists)" <email@hidden>
- Date: Fri, 28 Oct 2005 23:59:32 -0400
"Stockly, Ed" wrote:
> He's using Script Timer (2.3.1) to run a script every day at 6 am. The script
> opens a Filemaker database, runs a Filemaker script then quits Filemaker.
>
> When we run it directly from Script Timer or set Script Timer to run the
> script in a few minutes, it works flawlessly. But, when it's run in the
> morning it generates an error:
You should test-run your script in the same state as would exist at 6 AM. In
your local "right now" tests, you likely have FM already running, and
perhaps even have the DB file already open.
(There is little logical reason to suspect that the time of day has any
bearing on your script, of course. It's the conditions present which are
changing things.)
You also don't say which version of FileMaker you are using, whether the
FileMaker file is local or remote [your path, below, shows "FMServer01" but
we don't know where that is.
>> Wednesday, October 19, 2005 6:00:00 AM: Starting
>> <FM5MailDataNQ.app(RunMailScriptNoQuit)> . (Run Number: 34)
>>
>> Wednesday, October 19, 2005 6:02:06 AM: Error attempting to execute
>> <FM5MailDataNQ.app> Number -1713: No user interaction allowed.
>>
> We've contacted the Script Timer vendor and followed their suggestions
> (setting the wait time to 0) to no avail.
>
> Any suggestions? (The fairly short script is included below).
Given that the error is over 2 minutes into the script, I would bet that the
error is being generated by the AS script's 'quit' statement (while the FM
script's export script is still executing).
Again, possibly there are problems in your FileMaker script (which you don't
show).
I am guessing the 'quit' statement is reached _before_ the FM script
"[EXPORT]MailList" is finished running.
> tell the application "FileMaker Pro"
> activate
> open file "FMServer01:PhotoLabOMSbu:EMP_REC.fp5" with password "locust"
> do script "[EXPORT]MailList"
> quit
> end tell
If there is no real need to quit, then skipping that is an option.
If you really do want to quit the application, then one way to get a little
bit of "synchronization" between FM script state and AS script state, you
can use the simple "repeatedly poll a global field" method.
In this method, you have a global field in your FM file. This is a "still
running" flag field, with a 0 or a 1 as it's value (for example, you can use
any value you want: "red"/"green", etc.)
Create two FM scripts, of one statement each, much like:
[SUB]Stopped Set Field "FlagField" to "0"
[SUB]Started Set Field "FlagField" to "1"
Now, inside your FM file, use the "Execute Script on Open" preference to
execute the [SUB]Stopped script when the file opens.
Inside the [EXPORT]MailList script, add a new statement at the top
Perform Script [SUB]Started
and add a new statement at the end
Perform Script [SUB]Stopped
[Alternatively, of course, you can add the direct Set Field statements
inside your Export script. I do it this way, myself, because I often have
more than one script which might want to change the "state" of my flag
field. [SUB] is what I use to name short sub-routine scripts that I'll use
repeatedly from other scripts. You should season to taste and choose what
you like.]
Now, wrap your AppleScript 'quit' statement inside a repeat loop, such that
you continually check the value of the cell "FlagField" (or whatever you
named it.) When it is 0, then you can know the export is complete, and you
can then quit without error.
...
set isFinished to false -- or to (cell "FlagField" is "1")
repeat until isFinished
set isFinished to (cell "FlagField" is "1")
end repeat
quit
end try
...
Again...without seeing your Export script, I am only making a guess here.
(Although the workaround to synching scripts might be generally useful in
other regards.)
--
Gary
P.S.
I don't think you really need all the 'activate' stuff.
FileMaker can do its job completely hidden, without being front-most.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden