Friday, July 22, 2011

FileMaker TIP: Passing Multiple Script Parameters (FileMaker 8.5+)

If you do a lot of scripting (and what FileMaker developer doesn't?) - you can cut down the number of scripts (and globals) you have to create by using script parameters on objects. Since you can only send a single parameter to a script (like you can only send a single parameter to a plug-in) I've seen a lot of developers who use a delimited string to send multiple parameters (like you would in a plug-in call). Something like: "red|blue|green".

Then, in their script, they would parse that incoming parameter into 3 values.

But, here's an easier way - just use the List() function to pass the parameters in:  List ( "red" ; "blue" , "green" ) and then use GetValue() to reference the individual values: GetValue ( Get ( ScriptParameter ) ; 1 ). The result would be "red" for the first GetValue, "blue" if you change the number to 2, and "green" if you change the number to 3.


Assume we have this script:



Then we create a button and specify that the action is to perform the navigation script (at the bottom of the "Specify Calculation" dialog is the place to enter your parameters):


Now when you click the button - your variables are all set in your script:



This is way easier than parsing it all yourself!

5 comments:

Keith Hutchison said...

Thanks Bob. Very useful.

Cheers

Keith Hutchison

Winston said...

I'll echo Keith, VERY VERY useful. THANK YOU!!

Winston said...

I'll echo Keith, VERY VERY USEFUL! Thank you!!

Daniels said...

Thanks!

Daniels said...

Thanks!!!

Web Analytics