Re: AppleScript with FileMaker
Re: AppleScript with FileMaker
- Subject: Re: AppleScript with FileMaker
- From: Don Rossi <email@hidden>
- Date: Mon, 25 Jun 2018 14:34:15 -0400
Jim and David,
If you are running the script from inside Filemaker, you do not need the
tell "Filemaker …” block at all.
This is all you need in the script
tell database “my_db” — or layout, window, whatever…
…
end tell
With apologies to Matt Neuberg and Cal Simone, I can’t remember the term for
this. But whether you develop with Advanced and run with Pro, the scripts with
still work
> On Jun 25, 2018, at 1:27 PM, Ji <email@hidden> wrote:
>
> This is brilliant - thanks!
>
>> On Jun 25, 2018, at 1:24 PM, David Crowe <email@hidden
>> <mailto:email@hidden>> wrote:
>>
>> 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
>
> Jim Weisbin | C.T.O. | Human | Post Human |
> _______________________________________________
> 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
_______________________________________________
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