September 4, 200619 yr Can global variables be used to provide an auto-entered text string during a record create? I've tried every combination I can think of to specify the Auto-Enter of a predetermined value ($$CurrentText). Simply placing $$CurrentText in the Data option indeed causes "$$CurrentText" to be placed in the field, but not the contents of the variable. Placing it in a calculation doesn't work either, nor with any combination of "replace existing". If I make the calculation read: $$CurrentText & "TEST" the word TEST shows up, so the evaluation is taking place. BTW, Data Viewer displays the proper text string in the variable before and after the record create. Is this a limitation in the use of global variables? -- or have I just missed something? Thanks in advance for any help.
September 4, 200619 yr Hi AE $$CurrentText as calculation works with me, but the global variable must be definited before creating a new record. I can only think to suggest you to check the name of the variable. Edit: you can even force the re-evaluation with something like: Evaluate( Quote ( $$CurrentText ); AutoEnterField )
September 4, 200619 yr Author Thanks for the response. I've double-checked the name. And I've even tried wrapping the field in a GetAsText[] operation just to do something different, but nothing is returned in the field (... which, BTW, is indexed. I wonder ... ) Maybe tomorrow I can prepare a test file to try on other systems (v7 and v8). Thanks again.
September 4, 200619 yr $$Variables only exists for fm8+ and works only within the jurisdiction of one file. Use Get Script Result from an Exit Script to deal with trespassing. --sd
September 5, 200619 yr Author I am using the separation model -- and the record that's being created from the GUI is in the database file. Could that explain why it doesn't work for me? In other words, does this situation qualify as the two files you referred to?
September 5, 200619 yr Author So is there a way to bypass this limitation? -- or is it considered a brick wall? (BTW, I did not understand what Soren was suggesting.)
September 5, 200619 yr It's not quite clear when, where and why you set your variable/s. Here's one possible way: Script in file Main: Set Variable [ $$myVar; Value:"whatever" ] Perform Script [ “Receive Variable” from file: "Data"; Parameter: $$myVar ] Script “Receive Variable” in file Data: Set Variable [ $$myVar; Value:Get ( ScriptParameter ) ] Now both files have the same variable, with the same value.
September 5, 200619 yr Some cool trickery can be observed here: http://www.fmforums.com/forum/attachment.php?attid/5922/ ...however does it undermine the rigidness of separation model, when having scripts in both are becoming manditory --sd
September 5, 200619 yr Since $$global variables can't be referenced outside the file they're defined in, you can either pass the variable with a script as mentioned above, or simply use a global field instead. Global fields still have their uses.
September 5, 200619 yr Author Thank you each for your replies. Since my usage is fairly simple (tag each created record with a machine-dependent value) I'll just drop back to placing it in a global field (which, ironically, is where it started out). Variables are so "cool" that I began using them for all kinds of little things -- which led me across a line I didn't know existed. I'll explore the other examples you provided to gain more insight. Thanks again.
Create an account or sign in to comment