NVParse ( InNVPs )
Turns a Name=Value pipe-delimited list into $local FM variables.
Be the first to rate this function Log in to vote
Richard DeShong - Show more from this author
Logic Tools http://logictools.com |
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
InNVPs is one or more Name=Value pairs (NVP's).
If more than one NVP, then they are separated by the vertical-bar (|) character.
Values can have FM-returns (¶), but cannot have vertical-bars (|).
I mostly use this to pass one or more key values into scripts. When calling a script, I can create a "bar-delimited" name=value list right in the script parameter calc field.
Then in the called script, one Set Variable() statement creates all of the local variables in the list.
Example: if I want to pass 2 key values to a script, it looks like this:
Perform Script ["MyScript"; Parameter:"Key1=1234|Key2=Regular"]
And in MyScript I use:
Set Variable [$set_vars; Value: NVParse( Get( ScriptParameter ) )
and it will create two variables:
$Key1 with a value of "1234"
$Key2 with a value of "Regular"
NOTES:
(1) Because this is all text data, for numbers and dates you would need to use
GetAsNumber() and GetAsDate() to use them in calculations.
(2) Do NOT put spaces before or after the delimiters ( equal-sign or vertical-bar).
(2) A "vertical-bar" is |, and is Char( 124 ), and is sometimes called a "pipe" character.
(3) An FM-return is ¶, and is Char( 11), and is also called a "vertical-tab".
Comments
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.