![](templates/Classic/images/spacer.gif) |
xekon Apprentice
Joined: 11 Oct 2007 Posts: 154
|
Posted: 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 |
|
|
![](templates/Classic/images/spacer.gif) |
Larkin Wizard
![](images/avatars/169979204542c57c7448618.gif)
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: 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...) |
|
|
![](templates/Classic/images/spacer.gif) |
xekon Apprentice
Joined: 11 Oct 2007 Posts: 154
|
Posted: 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. |
|
|
![](templates/Classic/images/spacer.gif) |
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: 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. |
|
|
![](templates/Classic/images/spacer.gif) |
|
|
|
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
|
|