|
umdbandit Wanderer
Joined: 31 Oct 2004 Posts: 94
|
Posted: 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 |
|
|
|
tomcat025 Wanderer
Joined: 30 Dec 2001 Posts: 66 Location: USA
|
Posted: 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 |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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. |
|
|
|
umdbandit Wanderer
Joined: 31 Oct 2004 Posts: 94
|
Posted: 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 |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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. |
|
|
|
|
|