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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
umdbandit
Wanderer


Joined: 31 Oct 2004
Posts: 94

PostPosted: Wed Mar 28, 2007 5:27 am   

Variable isnt assigning
 
So, day 1 of CMUD, and I already like it..... But learning stuff!
So here's a quick alias to get something from my database and display it

#SHOW Statting %1
$temp=%query(&short="%1")
#SHOW temp is now $temp
#SHOW %dbget($temp)


$temp=%query(&short="%1") does not seem to be assignining anything, as in the line after that i put to check it, where $temp is, comes up empty. Anyways, my guess is I am doing something silly that one of you people will see instantly

Good Day, and thanks for your help
_________________
Rufus- Winner of Stuff
Reply with quote
tomcat025
Wanderer


Joined: 30 Dec 2001
Posts: 66
Location: USA

PostPosted: Wed Mar 28, 2007 5:51 am   
 
I am nowhere near being a guru but are you sure you have the syntax right?
Shouldn't it read something more like $temp = %query(&short = "%1")

Granted that I do not know what you are using $ for. Temporary variable?
_________________
You can pick your nose. You can pick your friends... but you can't pick your friends nose.

~Arwin Hochhauser
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Mar 28, 2007 5:55 am   
 
That's because in CMUD, quotes around something always mean that the contents are a literal string. But CMUD also doesn't mind if you're %nn variables contain spaces like zMUD did. Removing them should fix this right up.

This is one error that's caught by the compatability report. You can run it on scripts you've created as well as scripts you've imported to search for these common zMUD-to-CMUD errors.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
umdbandit
Wanderer


Joined: 31 Oct 2004
Posts: 94

PostPosted: Wed Mar 28, 2007 5:55 am   
 
yeah, the $ is for temporary variables, at least as far as i can tell.
_________________
Rufus- Winner of Stuff
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Mar 28, 2007 6:02 am   
 
Yes, they are, and they're MUCH faster than normal variables. One word of warning, though, local variables only apply to the script level they're defined at (and any below) so this:

#if (@lol) {$temp=yes} {$temp=no}
#say $temp

won't compile with an "invalid local variable" error. This:

#local $temp
#if (@lol) {$temp=yes} {$temp=no}
#say $temp

will work just fine.
_________________
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 General Discussion 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