SetVarsUsingNVPs ( InNVPs )
Creates local variables using Name=Value Pairs
Be the first to rate this function Log in to vote
|
Richard DeShong - Show more from this author
Logic Tools |
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
The parameter, InNVPs, is one or more Name=Value Pairs (NVP's).
If more than one NVP, then they are separated by the vertical-bar (|) or "pipe" 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: SetVarsUsingNVPs( Get( ScriptParameter ) )
and it will create two variables:
$Key1 with a value of "1234"
$Key2 with a value of "Regular"
NOTES:
(1)The use of "[R]" to substitute for "¶" can be replaced with any unique value - this means something that you know will not be in your data.
(2) Do NOT put spaces before or after the equal sign in the Name=Value pairs.
(3) This is expecting FM data -- so does not handle
(4) The data values cannot have the pipe characters in them - no list within list.
Comments
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.