Script Parameters

How do you manage Script Parameters?

SeedCode Complete 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:

Name = Value ; Name2 = Value2

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:

"ContactID = " & Contacts::_id & " ; Status = " & Contacts::Status

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:

$sc_Name would have the value "Value" ( without the quotes)
$sc_Name2 would have the value "Value2"

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.

Follow us: