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
caellin
Newbie


Joined: 21 Mar 2007
Posts: 2

PostPosted: Wed Mar 21, 2007 9:04 am   

%query and local variables
 
I can't seem to get %query to work with local variables
$damage contains decimating

then

$record = %query(damverb=$damage)
gives empty result

if I add
#VAR dam $damage
$record = %query(damverb=@dam)
it give correct record

edited
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Mar 21, 2007 4:33 pm   
 
I'm sure someone will correct me, but I believe you can't use local variables within functions, at least for now.
_________________
Asati di tempari!
Reply with quote
Zugg
MASTER


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

PostPosted: Wed Mar 21, 2007 5:33 pm   
 
You are mixing literal string values with your local variable. You should use %concat explicitly, like this:
Code:
$record = %query( %concat( "damverb=", $damage))

and see if that works any better.
Reply with quote
caellin
Newbie


Joined: 21 Mar 2007
Posts: 2

PostPosted: Wed Mar 21, 2007 7:46 pm   
 
I mistyped it here on forum, should have just copied from the script. Forgot the & when typing it on the forum.

this is how it really looks. and $damage is parameter in the alias.

$record = %query(&damverb=$damage)
gives no record at all.

and
#VAR dam $damage
$record = %query(&damverb=@dam)
gives the right record.
Only difference is using local variable first time.
And second time I copy that variable to another global variable, and then it works.

Tech probably explained it anyway, with not being able to use local variables withing functions. But just corrected what I missed first time anyway.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Mar 21, 2007 9:58 pm   
 
Can't use local variables in functions!? What kind of absurdity is this!?

#alias test {$one=-285728
#say $one
$two=%abs($one)
#say $two
$three=%eval($two/2)
#say $three}

and, indeed, just about every other application you can think of. Zugg's suggested the proper answer, I think.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Thu Mar 22, 2007 7:42 am   
 
I stand corrected. My %query was the only time I tried it, and it didn't work. I'll have to update my scripts with Zuggs suggestion.
_________________
Asati di tempari!
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