EXPERIMENTAL
Complement FileMaker Custom Function to deal with spreaded parameters by JSON.ToVars FMCF, which returns (in current version) the json arrays as:
$p.data.to.0.address
$p.data.to.1.address
$p.data.to.2.address
when an item has an array value, as:
{address: [addres1,addres12,addres3 ]}
Then once spreaded as runtime variables from json using JSON.ToVars(json), this function puts back all existing variable sin the array dimension into a FM list from where you can work normally.
This just explores the local scope searching the "model" patern and puts all variables found in a list.
Can just trim or nest the patern for more complex models:...
VarArrayToList("$p.data.to.[]")
VarArrayToList("$p.data.arr.0.arr.[].item")
VarArrayToList("$p.data.arr.1.arr.[].item")
VarArrayToList("$p.data.arr.[].arr.1.item")
Dependencies:
Split(...args)
Join(...args) (no link, sorry, gist is comming)
use
pass a template of the variable structure putting a "[]" where the variable part will come, then the function explores the scope searching for potential model matches (until undefined/empty value is reached) and then groups them all back in a FM List...
VarArrayToList("$p.data.to.[].address")
Code
/// model = "$p.data.to.[].address"
While (
[
_model = model;
_arr = Split ( _model ; ".[]." );
_seed = LeftValues ( _arr ; 1 );
_param = RightValues ( _arr ; 1 );
_output = "";
_n=0
];
not IsEmpty ( Evaluate ( Join( List(_seed; _n; _param); "." ) ) );
[
_value = Evaluate ( Join( List(_seed; _n; _param); "." ) ) ;
_filteredValue = Substitute ( _value ; ["\\" ; ""]; ["$" ; ""] );
_output = List ( _output; _filteredValue ) ;
_n = 1 + _n
];
UniqueValues ( _output )
)
/*
in a context with:
$p.data.to.0.address = address1
$p.data.to.1.address = address2
$p.data.to.2.address = address3
VarArrayToList("$p.data.to.[].address") -> address1¶address2¶address3
*/