The FileMaker Get(ScriptParameter) Function

From Dwayne Wright PMP
Certified FileMaker Developer

WEB: www.dwaynewright.com
EMAIL: info@dwaynewright.com
TWITTER: dwaynewright
YOUTUBE: FileMakerThoughts

Please Note: If you are viewing this page in a news feeder, the images may get munged up a bit. For the best experience, please visit the journal directly by clicking (here). 

Well, you would be hard pressed to find a more important Get function for scripting than Get(ScriptParameter). This function is so darned flexible in scripting, it is challenge to describe it accurately!

I wouldn’t be surprised if I have readers saying to themselves, “I do scripts all the time and never heard of the script parameter.” On the other hand ...

I attended a session of the 2007 FileMaker Developers Conference in which the presenter, Jeff Hough, said that he has absolutely no scripts that did not require a parameter to be passed into it. When he said that, I immediately thought that was a bit silly. I didn’t feel that way at the end of his session though!

In FileMaker, you can have a button, a script or even a custom menu pass data (called a script parameter) to a script that it executes. So you can have two buttons that execute the same script but they can pass a different parameter to that script. Based upon what you pass via the parameter, that destination script will likely operate differently. The same is true for two scripts that both call upon the same subscript.

Here you can see the Specify Script dialog box that comes up when you attach a script to a custom menu, a layout button or use the Perform Script step within a script. See the area in which to define the parameter?

On the surface, passing script parameter data seems to be a rather mild addition but it provides a wealth of possibilities. The parameter can be literal text or a calculation. The calculation means the parameter can be dynamic and could contain almost anything!

The Get(ScriptParameter) will return what parameter was specified by the button/script/menu. The parameter information cannot be passed to subscripts directly. However you can set a global variable in a script equal to the parameter data and then it can be processed within any script in that file. Using global fields, you can even setup script parameters to pass between files. The data passed by the parameter can be very useful in scripts that use the IF script step for branching or within other functions that use logical branching functions like If, Case, Choose or Evaluate.

REAL WORLD EXAMPLE
Case in point, I have a dozen or so modules in my InBizness product. Navigation from one module to the next is all scripted, however is all all the same script. I just pass the appropriate parameter equal to the module I want to navigate to!


=
More info about the author and FileMaker in general, contact me at info@dwaynewright.com.

© 2008 - Dwayne Wright - dwaynewright.com

The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.