Pass Parameters to Applescrip

Hi Guru’s

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.

Thanks & regards

Gus

Hello.

This part guesswork part conceptual outline.

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

Hi McUsr,

Thanks for your response.

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:

updateWorkCalendarOfICal(“Week plan”, “Scheduling”, (current date))

But the following won’t work:

updateWorkCalendarOfICal(Date_Due, Notes, Item)

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.

Best regards

Gus

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. :slight_smile:

Hello McUsr,

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!

Regards
Gus

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}.

Hello.

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

Edit: I think you should have a look at page 15 in FileMaker 9 Scripts Reference which can be downloaded from here