|
The Raven Magician
Joined: 13 Oct 2000 Posts: 463
|
Posted: Fri Aug 17, 2007 6:14 pm
[1.34] #VAR $var {...} broken; cannot create variables named with $vars. |
#ALIAS working {
var = "Foo"
#VAR @var {Bar}
#ECHO @Foo
}
The output of running this is, as expected, 'Bar'. The @Foo variable is created (as is the useless @var variable)
Now, the smart programmer would try to take advantage of the new temporary variables to streamline the code:
#ALIAS broken {
$var = "Foo"
#VAR $var {Bar}
#ECHO @Foo
}
Not so good. The output is a blank line, because the @Foo variable is not created. In fact, #VAR tries to create a variable with a blank name. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Aug 17, 2007 6:30 pm |
Not a bug - the #var command can also be used to directly edit the values of local variables. To edit a variable named dynamically with a local variable, use
#var %eval($local) {value}
as in
$test=olol;#var %eval($test) {wow};#say @olol
I guess this is another thing that needs adding to the help. |
|
|
|
The Raven Magician
Joined: 13 Oct 2000 Posts: 463
|
Posted: Fri Aug 17, 2007 7:33 pm |
Ahh, gotit. Thank you.
|
|
|
|
|
|