|
ardwick Novice
Joined: 31 May 2007 Posts: 32
|
Posted: Tue Dec 04, 2007 7:06 pm
#query and local variables |
I've been trying to clean up all my variables and use local variables where I can.
I noticed that when I changed my #query commands from regular variables to
local variables, I no longer get any hits in the database.
Saw some other stuff about local variables not working, thought maybe this may
be another aspect of this or could just be bad coding. Example below
#if ($search=Level)
{
$low = %prompt("","Level Minimum:")
$high = %prompt("","Level Maximum:")
#query ((&mob_level >= $low) && (&mob_level <= $high)) level
}
{}
Before if used @low or @high instead of $low,$high, it worked. This also works if I hard-code a value in the script. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Dec 04, 2007 10:30 pm |
The #QUERY command takes a string argument that is used to create a database filter. So you'd need to construct it like this:
#query %concat("(&mob_level >= ",$low,") && (&mob_level <= ",$high,")") level
The #query is executed by the old database module which was ported from zMUD and doesn't recognize local variables. So you have to trick it by expanding the value of the local variables using %concat and then sending the resulting string to #QUERY. |
|
|
|
ardwick Novice
Joined: 31 May 2007 Posts: 32
|
Posted: Wed Dec 05, 2007 3:14 pm |
Zugg wrote: |
The #QUERY command takes a string argument that is used to create a database filter. So you'd need to construct it like this:
#query %concat("(&mob_level >= ",$low,") && (&mob_level <= ",$high,")") level
The #query is executed by the old database module which was ported from zMUD and doesn't recognize local variables. So you have to trick it by expanding the value of the local variables using %concat and then sending the resulting string to #QUERY. |
This didn't work. However if you do something like $local_variable = %concat("(&mob_level >= ",$low,") && (&mob_level <= ",$high,")") and then #query ($local_variable) level: it works perfectly. |
|
|
|
|
|
|
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
|
|