Software Venture Consulting

FileMaker Pro downloads & Resources
FileMaker Custom Functions
FileMaker Web Viewer Examples
FileMaker Pro & Lasso Consulting
FileMaker Books
FileMaker Articles
FileMaker Error Reference

Free Web Tools
Free FileMaker Tools

Personal Pages

Shopping Cart
Shopping Cart


Free Newsletter


Privacy Policy

FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.


 FileMaker Pro Custom Functions

List  |  Show Random  |  Upload  |  Add This to Your Site


Rate this function:  

  Average rating: 3.7  (49 votes)
  Discuss this Custom Function

steve harley, paper-ape

automatically turns named script parameters into local variables

Sample Input:
If [ get_params ]
Sample Output:
returns 1 for success or 0 if parameters were malformed

(operates via the side effect of creating local variables for each script parameter)

 Then copy & paste into FileMaker Advanced's Edit Custom Function window.


this function supports a powerful technique for passing multiple/optional named parameters to scripts; it is specific to FM8+, and relies on the feature that Let() can create local (and global) script variables, even from a within custom function

the principle is that a script is called with a string parameter of the form

"$param_name1 = value1 ; $param_name2 = value2"

the parameter string will be wrapped with Let() and Evaluate(), using the well-known technique of passing multiple named parameters; however since the names are prefixed with "$", the ordinarily "temporary" variables created will instead persist outside the Let() to become local script variables

if the evaluation succeeds, get_params will return 1; if there is an evaluation error (usually because of a malformed parameter string), Let() returns an undefined value, hence the test for equality to 1 (it's not as redundant as it seems), so my pattern is to call get_params() within an If statement at the top of a script both to automatically set local variables and to catch gross errors in the parameter string

the script that receives the parameters may preset a default value of a local variable prior to calling get_params, and if the variable is defined in the parameter, it will override the default; if the value is not defined, the default will prevail, thus one can intuitively specify optional parameters to a script

the main limitations have to do with the fact the overall script parameter must be a string; within the string, escaping of substrings is necessary; the general case is illustrated by this parameter, from which get_params will assign to the script variable $num_files a numeric value of 3 and to $filename_prefix a string value of "foo"


another issue is that, due to an Evaluate feature, line ends within parameter substrings are converted to spaces; substitution of a proxy character (such as a vertical bar) is the recommended work around

i use this technique along with a naming scheme for scripts which includes the parameter names and whether they are optional; for example a script might be named

create_files($filename_prefix[; $num_files=5])

which indicates the two parameter names, and that if $num_files is omitted it will take a default value of 5; i find this naming scheme, in addition to being self-documenting, makes it much easier to remember the parameter names while setting up the parameter in a Perform Script step

in this case the script might read:

Set Variable [$num_files; 5 // the default value]
If [not get_params()]
// handle an error with the parameter string (i usually log it and return a fail value from the script)
// normal processing; param values are now defined; the rest is just example and is not relevant to the concept
Exit Loop If [$num_files < 1 // default value or passed value]
// other actions here
Set Variable [$num_files; $num_files - 1 // decrement loop counter]
End Loop
End If

(i would ordinarily avoid changing the value of script parameters, but in this case it makes the example simpler)

Note: these functions are not guaranteed or supported by Please contact the individual developer with any questions or problems.

This is my Custom Function and I want to edit it


There are no comments yet. Be the first to post a comment about this Custom Function! Please try to keep it brief & to the point. Anyone can post:

Your Name:
characters left. If you paste in more than 1500 characters, it will be truncated. Discuss the function - advertisements and other useless posts will be deleted.
Answer 7 + 2 =
Search for Custom Functions:

Custom Functions Widget
Download the Custom Function Dashboard Widget for OS X
Keep all the latest Custom Functions right at your fingertips!

Newest Custom Functions:

1. HexUUIDToNum_cf (_uuid)
  (Sat, Jun 16, 1:55pm)
2. httpResponseCode ( responseHeaders )
  (Tue, Jun 12, 10:40pm)
3. FindDuplicateCharacters ( string )
  (Fri, Jun 08, 5:01pm)
4. FieldRepetitionLast ( field ; maxRepetition )
  (Wed, Jun 06, 6:05pm)
5. CountModifiedRecords ( NameTimestampField ; StartTimestamp ; EndTimestamp )
  (Mon, May 28, 8:23am)
6. JSONArrayLength ( JSONArrayStr )
  (Fri, May 25, 7:46am)
7. interpolation (y1; y2; y3; x1; x2; x3; x1y1; x2y1; x1y2; x2y2; rnd)
  (Sat, May 19, 3:55am)
8. @JSONFormatElements ( json )
  (Tue, May 15, 3:31am)

RSS Feed of Custom Functions