For those who do not use Filemaker advanced, there is no way to create custom functions. For list, if you just pass it a list of values separated by "carriage return". The only problem is that if you passed a blank value, the next value will be used instead. This caused considerable inconveniences.
Some others passes a XML or JSON as parameter and it requires a function to do the extraction. I guess this is the best way to do it. The following is an example of getting the variable value by creating a XML, stored as global value and call the script with node name as parameter.
# Construct a xml for all the variable and values. Store as global variable $$xml # The passed xml must not contain carriage return just join all the nodes end to end # The xml constructed must also be escaped to make it valid.
Set Variable [ $pkey ; Value: Get(ScriptParameter) ] Set Variable [ $$xml ; Value: Substitute ( $$xml ; "><" ; ">" & ¦ & "<" ) ] Set Variable [ $ccount ; Value: 1 ] Set Variable [ $pcount ; Value: PatternCount ( $$xml ; ¦ ) ] Set Variable [ $pvalue ; Value: "" ] Loop Exit Loop If [ $ccount > $pcount ] Set Variable [ $xsearch ; Value: GetValue($$xml;$ccount) ] Show Custom Dialog [ "test" ; $xsearch ] If [ PatternCount ( $xsearch ; "<" & $pkey & ">" ) =1 ] Set Variable [ $pvalue ; Value: Let ( [ $p = Substitute ( $xsearch ; "<" & $pkey & ">" ; "" ) ; $p = Substitute ( $p ; "</" & $pkey &">" ; "" )] ; $p ) ] Set Variable [ $ccount ; Value: $pcount ] End If Set Variable [ $ccount ; Value: $ccount+1 ] End Loop Exit Script [ Result: $pvalue ]
Note that the | symbol is actually the Filemaker "carriage return" sign.
No comments:
Post a Comment