Re: Filemaker 8.5 stored applescript problem
Re: Filemaker 8.5 stored applescript problem
- Subject: Re: Filemaker 8.5 stored applescript problem
- From: "Stockly, Ed" <email@hidden>
- Date: Tue, 15 May 2007 13:07:33 -0700
- Thread-topic: Filemaker 8.5 stored applescript problem
Wow, I've gotten a bunch of questions off-line on this, and there seems to
be some confusion, so, here's the issue in a nut shell.
A read command in a script that runs from inside Filemaker consistently
generates an error.
What's happening is a terminology conflict that occurs when Filemaker loads
and tries to compile the script. This particular error is being generated by
a conflict between Filemaker's own read commands and the read command from
the standard additions OSAX.
The root cause is that when a script is run from within filemaker it's being
run as if it were in a "tell application filemaker" block and all the
script's commands go to Filemaker, unless explicitly sent to another
application.
My guess would be that others who have noticed scripts working from script
editor that fail when run from within Filemaker are seeing the same problem
in one form or another.
The two questions that arise from this problem are:
How to make the command work?
How to write scripts so that these conflicts will appear in Script Editor?
To make the command work, enclose commands in a "Finder" tell block.
Another answer is to use raw apple event codes.
To make the conflicts appear when editing in Script Editor, put the commands
inside a "using terms from application "Filemaker" block. (Also putting
everything in a tell application "Filemaker" block would work).
If you do that, you'll get the same behavior in Script Editor as within
Filemaker.
>Malcolm> The simplest, most unambiguous way to get around the terminology
conflict is to use raw codes.
>Me> I disagree here, I'd say that is among the most ambiguous way to get
around terminology conflicts.
>Malcolm> It depends on what you mean by unambiguous ;-) I'll go with
"exhibiting no ambiguity".
I generally go with dictionary meanings (English, not AppleScript) and in
mine it means ambiguous means "not clear; indefinite; uncertain."
When I see raw AE code (and 'code' is definitely the right word) it's
meaning to me is often not clear.
> And you may make the mistake of thinking that the code is addressed to you.
That's very ego-centric. The code is talking to the AppleScript interpreter.
I don't consider that a mistake. Given the extraordinary work Apple has done
over the years to make AppleScript readable to English-speaking humans (as
opposed to code-talking computers).
I believe the best solutions are those that allow the script writer to using
AppleScript's English-like syntax, as its creators intended.
>> The simplest way is to put the offending command in a tell. I usually use
tell application "finder" to yada yada
> That is simple but in the bad way not the good way. Read is a command from the
standard additions osax, not the finder. Why not tell Font Book or Safari or
Mail to do it?
Well, actually, that's one of the beauties of AppleScript, you can. If I
were working in a script that required Font Book or Safari to be up and
running, I just may do that (or if there happened to be a Finder terminology
conflict). I use the finder because it's always running, if you were to send
those commands to another application it may have to launch which really
slows things down.
The point is, when running a script from inside Filemaker you are implicitly
telling Filemaker to do those things anyway, which would be fine if there
weren't a terminology conflict. Telling Finder instead of telling Filemaker
may not add any time at all (I haven't tested).
So now I've heard that putting the read command inside a "Using terms from"
block also seems to work, and that saves the few ticks that sending the
command to Finder uses. (again, I haven't tested)
>>> -- let's be silly
> tell application "Calculator" to list disks --> {"Macintosh HD", "Network"}
> tell application "iPhoto" to path to desktop --> alias "Macintosh
HD:Users:creator:Desktop:"
If you think that's silly think about this, I almost always keep OSAX
commands inside tell blocks. So, commands like those, getting sent to even
sillier applications seem perfectly fine to me.
>>> Hey, who cares if they're a bit slow!
We're literally talking a few ticks here and there. The only times I make an
effort to remove OSAX commands from application tells is if I'm working on a
script that's processing thousands of calls or if there is a terminology
conflict (which are surprisingly rare).
ES
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden