Dynamic VariablesDynamic VariablesPosted by: aflgenx / Tuesday, June 26, 2007 – 7:10am
Hi Guys, I recently had the need (or more likely the desire) to set global variables dynamically.. As most of you will know, Set variable allows you to specify a dynamic value and repetition, but not a dynamic name for your variable. This often leads you to store info in a delimited list within one repetition when you need to store multiple peices of information per one subject. This will soon make your scripts become messy and the logic harder to follow Hence two small custom functions: Custom Function: SetGlobalVariable( name ; value ; repetition) Example Usage: SetGlobalVariable( "record_" & table::primaryKey ; table::aField ; 1 ) If your primaryKey field contained "991" and your aField field contained "Alex!!" - Which means that if you were to now retrieve the value of $$record_991 - you would get "Alex!!" as the value returned. Call: GetGlobalVariable( name ; repetition) Custom Function: GetGlobalVariable( name ; repetition) Example Usage: GetGlobalVariable( "record_" & table::primaryKey ; 1 ) These examples aren't great, but they certainly simplify my scripts and I hope they'll help someone else out. |
Be Notified!Let us tell you when a new video is posted. We'll send you an email with a direct link right to your email inbox.
Make sure and whitelist (or add to your address book editor@filemakermagazine.comFileMaker Reference Tool
* $29.99 is the FMPug member price for a printed copy. 10 Most Recent Videos
|