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
xekon
Apprentice


Joined: 11 Oct 2007
Posts: 154

PostPosted: Wed Apr 02, 2008 7:03 pm   

ROOM LOOKUP MAPFILTER Please help
 
I have been using the following to loopup my rooms:
Code:
#call %mapfilter(%concat(Name='%replace(@roomnamestring,"'","''")'))

However, sometimes a room has Graffiti or a PK flag on the end of the room name, so

"A Prison Cell"

can actually be

"A Prison Cell (G)"

or

"A Prison Cell [**> PK <**]"

How Would I do my mapfilter to also catch the rooms with graffiti or PK flags
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Wed Apr 02, 2008 7:25 pm   
 
Try this:
Code:
#CALL %mapfilter(%concat("Name LIKE '%", %replace(@roomnamestring, "'", "''"), "%'"))


(I'm assuming that roomnamestring will be looking for "A Prison Cell" in any of these cases. If it's the other way around, you'll just need to strip the extra codes from your variable instead...)
Reply with quote
xekon
Apprentice


Joined: 11 Oct 2007
Posts: 154

PostPosted: Wed Apr 02, 2008 7:32 pm   
 
Correct roomnamestring would be "A Prison Cell"

if I only wanted a wildcard for the end of the room it would be like this right: (not sure if i was supposed to remove the all the first section or leave in a quote or single quote....)

Code:
#CALL %mapfilter(%concat("Name LIKE %replace(@roomnamestring, "'", "''"), "%'"))


or

Code:
#CALL %mapfilter(%concat("Name LIKE '"%replace(@roomnamestring, "'", "''"), "%'"))


hehe Nevermind number 2 seems to work, Thank you very much for your help, now it finally works the way i wanted.
Reply with quote
Anaristos
Sorcerer


Joined: 17 Jul 2007
Posts: 821
Location: California

PostPosted: Wed Apr 02, 2008 11:40 pm   
 
Another way would be:
Code:

  $name = %replace( $room, "'", "''")
  $query  = %concat( "'", $name, "'")
  $queryg  = %concat( "'", $name, " (G)", "'")
  $querypk  = %concat( "'", $name, " [**> PK <**]", "'")
  $querycm   = %concat( "'", $name, " [**> CMAZE <**]", "'")
  $querygpk  = %concat( "'", $name, " (G) [**> PK <**]", "'")
  $querygcm = %concat( "'", $name, " (G) [**> CMAZE <**]", "'")
  $name = %concat( "Name IN (", $query, ",", $queryg, ",", $querypk, ",", $querygpk, ",", $querycm, ",", $querygcm, ")")
  $result = %mapquery( $name)

It seems like a lot of work, but I am trusting that, even with all this prepping, %mapquery is faster than %mapfilter, which may matter when used with a 28K+ room database.
_________________
Sic itur ad astra.
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