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


Joined: 15 Jun 2006
Posts: 7

PostPosted: Mon Jan 22, 2007 6:50 am   

%mapquery question
 
Alright.. I've been up/down inside and out of mapquery and the related commands.. gettng fairly comfortable using them.. Here's what I'm wondering.

When I'm searching for a room name that has an apostrophe in it.. is there any way I can get it to successfully search for the room. As it stands I think the apostrophe is screwing up the SQL script.

Any way to manage this?

I'm probably going to wind up with a couple more questions before this whole script is said and done, but I'd like to tackle it one at a time for the present. Thanks.


P.S. If you're -really- good with this sort of stuff.. my aim name is Thorinofrizion. If you've got the time.. I've got the questions.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Jan 22, 2007 2:56 pm   
 
You have to double the apostrophes up in order to make them part of the search string, this is an SQL standard type thing. Use '' instead of '
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Lyradil
Newbie


Joined: 15 Jun 2006
Posts: 7

PostPosted: Mon Jan 22, 2007 8:16 pm   
 
Alright.. here's the script question then..

How would I manage changing ' - " in a room name that I capture?



-edit-


After that is solved, would searching with the roomname with " match the roomname with ' in the map? I found out that it'll successfully query like that.. so that question is answered

Any help with the first question?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Jan 22, 2007 8:27 pm   
 
Note that Vijilante posted ''. That's TWO APOSTROPHES and not a single quote mark. Try highlighting it. In this case, the first apostrophe tells the query that the second isn't a special character.

You can change one apostrophe for two by using %replace:

%replace(%-1,"'","''")

that's a lot of little cashes. The first is a single apostrophe enclosed in quotes: " ' "; the second is two " '' ".
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Lyradil
Newbie


Joined: 15 Jun 2006
Posts: 7

PostPosted: Tue Jan 23, 2007 12:12 am   
 
Okay.. it's not quite working yet. Here's what I have:

Alias: RF

Value: #if %pos( %-1, "'") {#VAR RF {%replace( %-1, "'", "''")}} {#var RF {%-1}}

-------------------------------

Here's what I expect it to do:

RF Mermaid's Tail Bait and Bar (That's the room name)

To Capture it and replace the apostrophe with two apostrophe's, and store the corrected version in @RF

The False Value of the IF statement works.. I.E.:

RF Tail Bait and Bar (partial room name)

Stores Tail Bait and Bar into @RF


Thoughts?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Jan 23, 2007 12:16 am   
 
What's it doing wrong when you give it the first pattern?

EDIT: Note that you don't actually need the #if at all. If there are no apostrophes, the replace won't do anything. It could be that the #if isn't properly identifying names containing apostrophes, so see if it's doing that or if it's the %replace that's at fault.
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Tue Jan 23, 2007 1:24 am   
 
Fang is dead on, it's breaking because it would correctly be %pos("'",%-1), noting the reversal of arguments, however you don't need the IF at all and I recommend removing it.
Reply with quote
Lyradil
Newbie


Joined: 15 Jun 2006
Posts: 7

PostPosted: Tue Jan 23, 2007 2:24 am   
 
Alright.. I can't quite figure out how to write it then.. because if I'm removing the if statement, I'm going to be removing parts of the script.. would someone mind re-writing it for me with the if removed? I'm not quite sure how it goes.
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Tue Jan 23, 2007 3:38 am   
 
#VAR RF {%replace( %-1, "'", "''")}

That's all you need.
Reply with quote
Lyradil
Newbie


Joined: 15 Jun 2006
Posts: 7

PostPosted: Tue Jan 23, 2007 5:12 am   
 
Okay next part to the script.. :P

How do you do a mapquery when you know that the exact room name is -always- going to be used?

In the game I play we have skills to sense the exact room someone is in. If I sense someone that is in a room named "Blue Road" and there is also a room title elsewhere along the lines of "Passing a blue road".. but I know the person is at "Blue Road" without question.

How do I get it to exclude everything that isn't -exactly- "Blue Road"?

-------------------
Trigger:
You see that (*) is at (*).


Value:

#var rooms {%2}
#var senserf {%mapquery( { [Name] Like '%@rooms%'})}
#echo You see that %1 is in: {%zonename( %roomzone( {@senserf}))} at @senserf.
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Tue Jan 23, 2007 11:36 am   
 
Remove the %s from inside your mapquery, percentage signs are wild cards in this case.
Reply with quote
Lyradil
Newbie


Joined: 15 Jun 2006
Posts: 7

PostPosted: Tue Jan 23, 2007 4:23 pm   
 
yeah that's the weird thing.. when I remove both %'s it doesn't work.. might be some anamoly with the room name though.. Thoughts?


-edit-

I mean that the mapquery doesn't work at all..btw
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Tue Jan 23, 2007 7:17 pm   
 
Make sure you've really got the exact room name, for example some skills in a game I play will show you the room name without a period on the end and my map stores the actual room name (which has a period on the end)... similarly, check for extra spaces (e.g. at the end of room names) in your map file.

If you try
#show %mapquery([Name] LIKE 'Blue Road')
#show %mapquery([Name] LIKE '%Blue Road')
#show %mapquery([Name] LIKE 'Blue Road%')
you might be able to pin the error down a little bit better. All of the above examples worked for me, using a room name that I have in my map.
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