About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 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
saet
Apprentice


Joined: 12 Jun 2006
Posts: 106

PostPosted: Tue Nov 14, 2006 8:58 am   

Syntax Check Error - Local Variable
 
The syntax checker is bugging out on local varibles.

$test = 1

is fine to it, but

#SHOW $test or #IF ($test = 1)

is causing the syntax checker to say it's an invalid local variable.

Also could it report the row numbers starting with 1 instead of 0? It's confusing and we aren't all programmers who like to count from 0 ;)
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Nov 14, 2006 11:21 am   
 
What exactly are you using those scripts in? The only circumstances I can think of where that would happen are where you're using more than one local variable as a named parameter in a trigger (which is a bug) or where you really are using an invalid local variable. For a local variable to be valid, it has to be defined in the same script (trigger, alias, user function) or on the same command line.

$test=1;#if ($test) {yes} {no}

should be working fine, for example. I'll post a confirmation once I'm on a computer with CMUD installed :)
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Tue Nov 14, 2006 12:52 pm   
 
The syntax checker appears to point to a local variable as being invalid when it's not declared with #LOCAL, though the variables can be implicitly created and aren't really invalid. I saw a similar syntax error when I created an alias with a local variable as a parameter name. It doesn't see the parameter as being a valid local variable. I believe the same is also true of named wildcards in trigger patterns.

Code:
#ALIAS test($param) {#show --$param--}
#TRIGGER {^($param:%w)$} {#show --$param--}
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Nov 14, 2006 2:47 pm   
 
My example above works fine, as do your two examples Larkin. Problems only seem to come if you use more than one local variable in the same trigger (which is already on the list).
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
saet
Apprentice


Joined: 12 Jun 2006
Posts: 106

PostPosted: Tue Nov 14, 2006 2:52 pm   
 
Hmm #alias test {$test = 1;#SHOW $test} is all I used. I have a more complex alias that I first noticed it on. But I get the same "error" on the test alias.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Nov 14, 2006 2:56 pm   
 
That example works perfectly for me, pasted on the command line or entered manually through the GUI. Are you on 1.15?
Reply with quote
saet
Apprentice


Joined: 12 Jun 2006
Posts: 106

PostPosted: Tue Nov 14, 2006 3:33 pm   
 
Still getting it with a fresh install. Should have been a little more informative on my first post. The alias works fine, just the syntax checker throwing an error. I'm just talking about the syntax checker not liking it. Everything compiles and runs fine.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Tue Nov 14, 2006 8:26 pm   
 
Confirmed. Not sure why the syntax editor causes an error since it should be doing the same as compiling. Sounds like a bug with the syntax check menu option.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Nov 14, 2006 11:42 pm   
 
It's very bizarre that I can type that exact same thing with no syntax error, no compile error, no nothing then Confused
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Nov 15, 2006 12:28 am   
 
Are you using the settings editor? Click Aliases, click New Alias. Enter a name (test) and enter

$test=1;#if ($test) {yes} {no}

in the value field. Click Save Changes. Click the compile tab...notice they compile. Press Ctrl-K to check the syntax. Error "invalid local variable".

Btw, that's usually the kind of specific procedure that I like to see posted for bug reports. There are too many ways to do things in CMUD (like zMUD) and without specifics, it can be hard for people to reproduce problems.

And I have to admit that if I can't reproduce something, it drops way down on my priority list.
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Wed Nov 15, 2006 4:33 pm   
 
I had a script that I was editing in the editor window. I added some new code that didn't get parsed properly and caused goofy settings. I wanted to find where the problem was, so I used the Ctrl-K syntax checker in the editor window (not the settings editor), and the "error" it flagged was an invalid local variable above where the real problem was located. Since the syntax checker doesn't do a full compile and give a list of all warnings and errors, this first one precluded me from seeing the real problem, which is really why I'd like to see the parser fixed to handle the implicitly declared local variables.
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