Re: AppleScript with FileMaker
Re: AppleScript with FileMaker
- Subject: Re: AppleScript with FileMaker
- From: David Crowe <email@hidden>
- Date: Mon, 25 Jun 2018 11:24:07 -0600
Jim;
You asked how to adapt software to run scripts that access “FileMaker Pro” or
“FileMaker Pro Advanced”.
This is difficult to do in AppleScript because you can’t just say:
set FileMakerType to “FileMaker Pro Advanced”
tell FileMakerType
…
end
You have to arrange for the right dictionary, which I think is possible.
However, it is much easier to do this from FileMaker, since it knows what it
is, using the following to set a field (probably a global), upon opening your
application to:
If(
LeftWords( Get(ApplicationVersion); 1 ) = "ProAdvanced";
"FileMaker Pro Advanced";
"FileMaker Pro"
)
Note that there are several other FileMaker application names (Server, xDBC
etc) but you are probably only running scripts from either Pro or Pro Advanced
(until Filemaker changes its naming conventions again).
Now you can run a FileMaker script that encapsulates the AppleScript as such:
Command: Set Field
Field: g::AppleScript
Value:
"tell application \"" & g::FileMakerType & "\" to tell layout \"g\"¶
tell first record¶
set cell \"ScriptResult\" to path to documents folder as string¶
end¶
end tell"
Command: Perform AppleScript
Field: g::AppleScript
The reason I write the applescript to a field before executing it is because
the field contains the actual applescript that is going to be executed which,
in this case is:
tell application "FileMaker Pro Advanced" to tell layout "g"
tell first record
set cell "ScriptResult" to path to documents folder as string
end tell
end tell
I pasted it into Smile to get the nice formatting. So, if I ran this from
“FileMaker Pro” then the script would be changed accordingly before execution.
Note that the FileMaker field “ScriptResult” may be a global, but the table “g”
must have at least one record otherwise the script will fail. I usually set up
a table called “g” in any of my applications, and make sure it has one record
in it whenever the FileMaker application is opened.
Finally, this illustrates how to write back the result of an AppleScript that
is called from FileMaker. I think that this is more flexible and reliable than
using the clipboard, since you can easily write different information into
different fields, you can create new records, and whatever else you need to do.
- David Crowe
Attachment:
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________
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