Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
jed
Adept


Joined: 18 Dec 2005
Posts: 246

PostPosted: 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?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net