|
jed Adept
Joined: 18 Dec 2005 Posts: 246
|
Posted: Sun Jun 03, 2007 3:23 pm
[1.33] Temp variable error possible bug |
I have an alias that has the following script:
Code: |
#if (@item.minlevel = {}) {#say bluhey} {$templev = %concat( {@item.minlevel},L);#say $templev;#say crapper}
#say $templev |
the @item.minlevel has the value of 12
If I run this alias as is, I get
Code: |
ERROR: Syntax error in Alias: asdff : invalid local variable: templev
|
but if I comment out or delete the last #say $templev it shows the output from the #say $templev in the else part of the if statement. This looks to me like a bug. Why would it work within the if statement but not outside the if statement..... Temp variables arn't supposed to expire after going through an if statement are they? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Jun 03, 2007 4:21 pm |
It's not a bug, it's to do with the scope of the local variable. You defined it within the #if statement, so it's removed when it ends. By the time the #say command runs, the variable's out of scope. If you want the variable to stay in scope for the whole alias, you need to define the variable with #local from outside the #if statement.
Also, your %concat syntax seems a bit weird. Unless you literally mean for the value of @item.minlevel to be displayed surrounded by {}, you don't need them, and you might need to quote the L to ensure it's parsed properly as a string. |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|