Brian Dunning's FileMaker Custom Functions

NVPsLoop

Turns a list of name-value pairs into FM $variables

  Be the first to rate this function Log in to vote

Richard DeShong   Richard DeShong - Show more from this author
Logic Tools
http://logictools.com

Share on Facebook Share on Twitter

  Sample input:
NVPsLoop
  Sample output:
FM $Variables created from the list generated by NVPsInit().

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This is Part 2 of parsing name-value pairs into FM $variables.
I usually use this to parse the parameter sent to a script.
First, run NVPsInit( InNVPs ) to create the list of name-value pairs.
Second, run this function inside a Loop() to create local $variables for each NVP.

Example Script call: MyScript [ "This=That|Those=Them|When=Now" ]
I am passing Name-Value pairs in a vertical-bar delimited list.
Note that parameters can have returns (pilcro), but not vertical-bars.

Then within MyScript, I call this function, which converts the text string in a Name-Value list,
and then NVPsLoop, inside a Loop, which create FM $vars for each Name pair:
$This = "That"
$Those = "Them"
$When = "Now"

Here how that looks in a script to parse the script parameters:

Set Variable [$init_vars; Value:NVPsInit( Get( ScriptParameter ) )]
Loop
Exit Loop If [NVPsLoop // creates $vars from NVPs string]
End Loop

 

Comments

Log in to post comments.

 

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

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: