Script Parameters
How do you manage Script Parameters?
The SeedCode Complete and SeedCode Control files use two methods for passing parameters.
The first is to simply use the native functionality to pass a single value. When this method is used the script name should indicate this by putting the parameter name in square brackets.
Multiple Values using #Parameters
For passing multiple values in SeedCode Complete and SeedCode Control, we use the #Parameters module available here at Modular FileMaker. There's plenty of documentation there, but basically it's a collection of custom functions that allow you to pass multiple values as named value pairs to the parameter and then have them automatically assigned as local variables in the script. The basic syntax is
# ("sc_paramter" ; "Value ) where sc_parameter is the variable name and Value is the value passed.
Multiple Name Value Pairs can be passed like this:
# ("sc_paramter1" ; "Value1 )
& # ("sc_paramter2" ; "Value2 )
Inside the script you can then call the #Assign custom function like this
#Assign ( Get ( ScriptParameter) ) and your variables will be populated. We love this module.
Parameters in the Calendar
SeedCodeCalendar uses a script parameter syntax to make it easier for you to pass multiple parameters to a script. The syntax (the parameter you'd send to a script) looks like this:
When you're sending hard-coded information in a parameter, you can just type this into the parameter window when calling a script. If you're sending field data, you'll need to put quotes around the literal (the non-field) parts. Here is an example:
There are a few things to keep in mind about the parameters you can send in...
- Values within the parameter can include carriage returns: no problem.Parameters can not contain calculation syntax ( ; + - / = ) or quotes. If you need to pass values like these, use the custom function "SeedCode_EncodeOperators" and "SeedCode_DecodeOperators" (introduced in v 2.3) in the script parameters themselves. For an example of this see the scripts "New Invoice from Bid" toward the bottom where we call "Create Invoice Line.." (for an example of encoding of the line's description) and "Create Invoice Line..." for decoding of the description.The spaces around the semicolons and equals signs used to separate name value pairs is important: don't forget them.
How are parameters read by a script?
We use a separate script to parse the inbound parameters and return it to the original script as a script result; a second line in the script turns the result into local variables. So in our example above, our script would create two variables:
You'll see these two script lines (one for the parsing the parameter, one for turning it into local variables) at the beginning of many scripts. Take a look at "New Phone Fax Email { ContactID }" for an example.
You can add these two lines, without modification, to any script which you'd like to be able to understand multiple parameters.
Debugging Script Parameters
While our "Explode Parameters" script (the second one above) will let you know if your script parameters are poorly formed, you may want to follow the parameters in the Script Debugger sometimes as well (the script debugger is only available in FileMaker Advanced).
Here is a short video of how we do it.