|
ToyMage Apprentice
Joined: 01 Sep 2005 Posts: 120
|
Posted: 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? |
|
|
|
cazador Apprentice
Joined: 08 Dec 2005 Posts: 108
|
Posted: Sat Dec 17, 2005 9:32 pm |
use double quotes instead of a single quote
|
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: 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))} |
|
|
|
ToyMage Apprentice
Joined: 01 Sep 2005 Posts: 120
|
Posted: 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? |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Tue Dec 20, 2005 3:48 am |
It will also work like that I just like functions :P
|
|
|
|
|
|