RE: set variable to string containing variables to be evaluated later, tom, 07-19-2005
You may be over-complicating it ;-)
by Roger Harris, July 19, 2005 16:32
When you set a variable to a quoted character string, any embedded variable references are NOT evaluated at that point. When you USE that variable anywhere in the script, however, embedded variables will be evaluated at that point, UNLESS you use the $varstr( ) function (but I don't think that's what you need to do in this case).
Consider these statements:<!--SET x="Value of x"--> <!--SET y1="The value of x is $x$"--> <!--SET y2="The value of x is" $x$-->At this point, variable y1 will still be "The value of x is $x$" because the $x$ was inside the quotes; but y2 will be "The value of x is Value of x" because $x$ was evaluated during the SET statement.
Ordinarily, it may not make a difference if a variable reference inside another variable is evaluated when that variable is set or if it's evaluated when that variable is used somewhere in the script. For example, after the statements above, if you then use $y1$ or $y2$ anywhere in the script, the output will be identical, "The value of x is Value of x", because the value of $x$ hasn't changed. But any time that the value of an embedded variable changes between those two events, then it does matter. In your case, it does matter, because the embedded variables will change with each iteration through the EACHROW loop, and you want the current values in each row read from the database to be in the output line for that row.
(Hmmm... I guess it IS kinda complicated, but you just need to carefully observe the rules about embedded variables ;-)
Name E-mail optional TopicMessage:
HTTP Link: Link text: