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


Joined: 04 Jun 2007
Posts: 2

PostPosted: Mon Jun 04, 2007 8:59 am   

#query using a local variable problem
 
Hi all ..

First off a big thanks to zugg for CMUD. How are you finding Delphi 2007 ???

I have been slowly converting my ZMUD scripts to CMUD (v1.33) which for the most part has been quite smooth. Having said that I have just come across a problem when I try and run a #query with a local variable and I'm not sure if ...
(a) it can not work because of scope
(b) I am using the local variable incorrectly
(c) the database has not been updated to handle local variables yet
(d) something else I haven't thought of :)

If I use a normal variable my script works just fine so I do have a work around. I'm just curious as to what the problem is.

For testing purposes I have hard coded the variable and thrown in an echo. My old script that works with a normal variable is as follows ...
$spll = "unknown spell"
Incnttn = "PAF PAF PAF!"
#DBOFFLINE
#DBLOAD Sp
#QUERY (&Incantation=@Incnttn) Spells TRUE
#if (%numrec > 0) {$spll = %rec.Name}
#DBRESET
#echo "Spell Name =" $spll


This finds the correct result in my table and echoes "Spell Name = Harm Body".

If I try the same thing but make "Incnttn" a local variable the script never manages to locate the record .. My script now reads ...
$spll = "unknown spell"
$Incnttn = "PAF PAF PAF!"
#DBOFFLINE
#DBLOAD Sp
#QUERY (&Incantation=$Incnttn) Spells TRUE
#if (%numrec > 0) {$spll = %rec.Name}
#DBRESET
#echo "Spell Name =" $spll


This fails to locate the record and always echoes "Spell Name = unknown spell".

What do you think the problem might be ???

Thanks in advance ..
Reply with quote
Zugg
MASTER


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

PostPosted: Mon Jun 04, 2007 5:21 pm   
 
The database module is simply ported from zMUD, so it hasn't been integrated with the new CMUD features (like local variables) yet. The #QUERY command is passing it's argument as a string value, which the database module tries to parse. Since the database module doesn't know about local variables, this fails.

A workaround is to use %concat to form the string to be sent to the #QUERY:

Code:
#QUERY %concat("&Incantation=",$Incnttn) Spells TRUE


Oh, and I'm not using Delphi 2007 yet. I'm still waiting on some third party components to be updated, and then I need to find a week or so to get everything ported and working. It hasn't been really high on my priority list right now.
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