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


Joined: 09 Dec 2006
Posts: 7

PostPosted: Fri Jul 06, 2007 9:34 pm   

Mapquery with special characters
 
Okay, so if a room is titled Moolb's Awkward Home, this will return nothing:
#echo %mapquery( "Name LIKE '%Moolb's Awkward Home%'")
Because of the ' character. If I am doing a manual search I know I can just do a search for Moolb''s Awkward Home and the room number will be returned.
However, if I'm trying to automate some things and I just have a variable called @roomName then I can not easily add that extra apostrophe in there.
I realize with a line or two of code I can take apart @roomName and detect if there is an apostrophe and fix it, but that seems like to much work.

Is there a way with the SQL syntax or any other way with Mapquery where I can tell the parser/whatever to ignore a special chatter like an apostrophe?

Anyway, thanks for any feedback that might come.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Fri Jul 06, 2007 11:02 pm   
 
Personaly I use a user defined function to comment out the 's by doubling them up. Writing this off the top of my head.

#FUNC sqlf($param) {%replace($param,"'","''")}

example

#ECHO %mapquery("Name LIKE '%" + @sqlf("My Room Name") + "%'"


edit: Added in missing }
_________________
Zmud Support Library
Zmud Knowledge Base

Last edited by nexela on Sat Jul 07, 2007 12:49 am; edited 1 time in total
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Fri Jul 06, 2007 11:24 pm   
 
This does the trick for apostrophes, or commas.

Code:
#show %mapquery(%concat("Name LIKE '%",%subchar("Moolb's Awkward Home","',","%%"),"%'"))
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
moolb
Newbie


Joined: 09 Dec 2006
Posts: 7

PostPosted: Mon Jul 09, 2007 9:30 pm   
 
Thanks Nexela, that worked great and was surprisingly easy. Didn't know about the replace command, thanks for the heads up :)
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