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. |
||
| Tjebbe van Tijen, IMP Oct 29, 2025 |
||
| only stumble across this useful functie now BUT this better fundtion can NOT be used... full of improper charcters at the wrong place... why not post a proper version... the problem starts with Let ( |
||
| Tjebbe van Tijen, IMP Oct 29, 2025 |
||
| mmm My globalValue name strings had the $$ characters in it, while I should have left them out... {I am just an amateur in the field say} now it works file and I use values from a repeating field using a get repeating field number functionality... now it works FINE... - example: fnSetGlobalVar ( GetRepetition ( about_fond::gColor_var_6x_X ; $count ); GetRepetition ( about_fond::gColor_RGB_6x_X ; $count ) ) well thank you for posting it 15 years AGO! |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.