How to pass parameters from external applications e.g. Filemaker to an applescript?
Sample Script:
tell application “iCal”
tell calendar “Work”
make new todo at end with properties {description:TDDesc, summary:TDName, due date: DDate}
end tell
end tell
Where TDDesc, TDName and DDate are global parameters that are defined in the external application.
You would do your stuff in iCal within a handler, which is an AppleScript subroutine, you then call the subroutine with the parameters you need, from within another AppleScript.
This is not test, this is just to show you the concept.
updateWorkCalendarOfICal("Week plan", "Scheduling", (current date))
” The call could be like above:
” you could of course store the values in variables before calling the handler.
on updateWorkCalendarOfICal(TDDesc, TDName, DDate)
tell application "iCal"
tell calendar "Work"
make new todo at end with properties {description:TDDesc, summary:TDName, due date:DDate}
end tell
end tell
end updateWorkCalendarOfICal
I’ve tried to use the call within the handler, but unfortunately it didn’t work. It seems the handler expects its arguments to be explicitly defined before passing. Therefore, the following call works:
where Date_Due, Notes and Item are all globally defined in the calling external program (FileMaker).
It seems to me that either Handlers cannot handle situations like the one above or the external program global parameters sees to be global when calling Applescripts.
I’m not sure if you observed that the parameters are in different order in the two calls.
In your first call, the date parameter is the last, and in the last call the date parameter is the first, those parameters you pass to handlers in between parenthesis in AppleScript are called positional parameters since their position influence how they will be interpreted internally in your script.
If I were you, I’d try the second example one more time, with the parameters in the correct order.
Thanks for pointing out the different order of the parameters. It is a typo on my side when I posted my response, however, the order is correct in my scripts that I was testing.
Still I have no luck in finding a solution to this issue!
A script receives parameters through a list passed to its run handler:
on run {TDDesc, TDName, DDate}
tell application "iCal"
tell calendar "Work"
make new todo at end with properties {description:TDDesc, summary:TDName, due date:DDate}
end tell
end tell
end run
I don’t know how Filemaker runs scripts. The equivalent in AppleScript is run script with parameters {this, that, theOther}.
I have looked at a couple of FileMaker examples, this is something they refer to as an “AppleScript Step” in their procedures.
They would then use just use the tell block of iCal within that code like this after maybe having created the correct variables. I have of course just seen a rather meagre selection of examples, but none of the ones I saw used a handler.
--Give your variables values here before sending them to FileMaker
tell application "iCal"
tell calendar "Work"
make new todo at end with properties {description:TDDesc, summary:TDName, due date:DDate}
end tell
end tell