Rob P Posted June 12, 2008 Posted June 12, 2008 (edited) I want to know if anyone has done this and how. Here's the situation, you want to create a global var on the fly. You don't know the name or value until you instantiate it. I was trying to create a script that would allow me to create a named var on the fly rather than explicitly naming it. My first attempt Let ( [ expression = "Let ( "$$" & myvar = myvalue" ] ; Evaluate ( expression ) ) results in an error because you cannot concatenate the name value in the LET statement. Second attempt Let ( [ var = "$$" & "myvar" ; val = myvalue ] ; Evaluate ( var = val ) ) returns zero and no global variable created. Edited June 12, 2008 by Guest
comment Posted June 12, 2008 Posted June 12, 2008 I don't quite see the purpose of this, but if you want it, you need to correct your first attempt so that the expression is (a) a valid text string and ( a valid expression: Let ( [ expression = "Let ( $$" & myvar & " = " & myvalue & "; 0 )" ] ; Evaluate ( expression ) ) This is assuming that the variables 'myvar' and 'myValue' have been defined and are available to the main formula.
Rob P Posted June 12, 2008 Author Posted June 12, 2008 That still did not work UNTIL I quoted the value. Thanks a million. You may not see it's purpose now but perhaps somewhere you'll want to declare a variable on the fly. Let ( [ expression = "Let ( $$" & $myvar & " = " & Quote ( $myval ) & "; 0 )" ] ; Evaluate ( expression )) And yes your assumptions are correct.
comment Posted June 12, 2008 Posted June 12, 2008 That still did not work UNTIL I quoted the value. Ah, sorry about that - I used a numerical value in my test, so it slipped by.
Recommended Posts
This topic is 6006 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now