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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
ToyMage
Apprentice


Joined: 01 Sep 2005
Posts: 120

PostPosted: Sat Dec 17, 2005 9:13 pm   

DB Query
 
I was very sure I saw someone asking this question but I can't find it.

Any it goes like this... I have a Alias as below:

#VAR QueryRoom %MAPQUERY( Name LIKE '%@QuestRoom%' AND ZONEID = %ZONENUM( @QuestZone))
#FORALL @QueryRoom {#SHOW %i, %ROOMNAME( %i), %ZONENAME( %ROOMZONE( %i))}

It works absolutely fine except when the room or area name has ' in it. Than it fails... How do i amend the %mapquery?
Reply with quote
cazador
Apprentice


Joined: 08 Dec 2005
Posts: 108

PostPosted: Sat Dec 17, 2005 9:32 pm   
 
use double quotes instead of a single quote
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sat Dec 17, 2005 10:10 pm   
 
You need to use a %replace(@QuestRoom) to replace the single quote with 2 single quotes I also think there are a few other things that need to be replaced but I can't remember them. Now because in the end it will look like '%%replace(@QuestRoom...... it wont work right due to delayed expansion so to bypass this and keep the Var readable use a function!

#FUNCTION rep_special {%replace("%1","'","'''")}
#VAR QueryRoom {%MAPQUERY( Name LIKE '%@rep_special(@QuestRoom)%' AND ZONEID = %zonenum( @QuestZone))}
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
ToyMage
Apprentice


Joined: 01 Sep 2005
Posts: 120

PostPosted: Tue Dec 20, 2005 2:13 am   
 
Hi,

I just did a simple replace

#VAR QuestRoom %replace(@QuestRoom,"'","''") and it works find.

I haven't encounted the delayed expansion problem so far... when does it happen?
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Tue Dec 20, 2005 3:48 am   
 
It will also work like that I just like functions :P
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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