Jump to content

[How To] Custom Function: ScriptParamByName

This topic is 7148 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I love the ability to use script parameters in FMP7 -- simplifies many things. However one thing I wanted to be able to do is to easily get specific parameters, either by number of by name. With Developer's custom functions it was straightforward to write a function that gets a parameter by name:

Custom Function "ScriptParamByName(Name)":

//ParamPair is a mapping of a parameter to a value in the format "name: Value"

Evaluate(" Let([" & Substitute(Get(ScriptParameter);[":";"="]) & "]; "&name&" )" )


Calling a script with Parameters:

Note - it is helpful to list the paramNames in the Script name

Notice the parameter is constructed as "ParamName: Value"

Text has to be placed in escaped quotes

Perform Script["DisplayNames(Type; ID)"; Parameter: "Type: "Record"; ID: 422"]


Using the ParamName custom function in a script calculation

Script: DisplayNames(Type; ID)

Show Custom Dialog[scriptParamByName("Type")]

Show Custom Dialog[scriptParamByName("ID")]


There may be some glitches -- but the general gist is there. People may wish to suggest improvements.

FileMaker Version: Dev 7

Link to comment
Share on other sites

  • 7 months later...

Thanks for the How-To. I am going to use this technique, as keeping track of which word in the ScriptParameter is which parameter is driving me nuts (especially since FM considers the "-" a word boundary). I've modified your formula just a little to use a more classic command-line look, in the form of varname=value. It makes it easier for my eyes to pick up:

Custom Function


/* Takes argument param and extracts from ScriptParameter in form of */

Evaluate(" Let([" & Substitute(Get(ScriptParameter) ; ["=" ; "=""] ; [";" ; "";"]) & ""]; "&param&" )" )

All the rest is the same, except that you use a ScriptParameter like so: "Type=Record; ID=422"



Link to comment
Share on other sites

  • 3 weeks later...

I just noticed that my choice of terminology in my script causes Internet Explorer to mis-display my function (the ampersand combined with my variable name "param" gets converted to a paragraph mark and an "m". For those who are using IE, here is a modified version using "passvar" instead:

Evaluate(" Let([" & Substitute(Get(ScriptParameter) ; ["=" ; "=""] ; [";" ; "";"]) & ""]; " & passvar & " )" )

Link to comment
Share on other sites

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.