fnSetGlobalVar ( Name ; Value )
Dynamically sets a global variable with a single script line.
Average rating: 3.9 (54 votes) Log in to vote
Rob Poelking - Show more from this author
Kiza Solutions https://kizasolutions.com |
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
Allows the user to set dynamic global vars without having to explicitly script a named variable. So you can have a single line script set variable [$var] pass the parameters and create a global var on the fly or destroy it by passing the name with no value. I needed to declare a global variable in a different file and did not want to script just for that single variable. I wanted something I could reuse as needed
Comments
Vaughan Bromfield Apr 23, 2010 |
||
Rob, I have taken the liberty to change the function to allow the repetition to also be specified. My changes also have it return the evaluation error code s the function result. Many thanks for an excellent cf. --- begin // SetGlobalVar ( name ; repetition ; value ) // Author: Rob Poelking // Date: 20080613 // // Modified by Vaughan Bromfield to specify the repetition. // The function returns the error result from the evaluationn operation // which is zero when there is no error. // // This function does not check that the variable name is valid // other than filtering out non-alphanumeric characters. Let ( [ nameclean = Filter( name ; "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz1234567890" ) ; repetitionclean = Int( GetAsNumber( repetition ) ) ] ; EvaluationError( Evaluate ( "Let ( $$" & nameclean & "[" & Max( repetitionclean ; 1 ) & "] = " & Quote ( Value )  & "; 0 )" ) ) ) // end let /* Notes: Allows the user to set dynamic global vars without having to explicitly script a named variable. So you can have a single line script set variable [$var] pass the parameters and create a global var on the fly or destroy it by passing the name with no value. I needed to declare a global variable in a different file and did not want to script just for that single variable. I wanted something I could reuse as needed. */ --- end |
||
Rob Poelking, Kiza Solutions Apr 23, 2010 |
||
Very good, I had actually done this myself already. I just hadn't updated this. However, I've started using a set of functions from Fabrice Nordmann for keeping a log of variables. VariablesLog, VariablesResetAll and LoadVariablesFromLog. They're very powerful and I highly recommend them. Nevertheless, this is still a great function for what it does. Thanks. |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.