Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sat Nov 03, 2007 4:16 pm   

[2.10] %mapquery removes whitespace unless in double quotes
 
There appear to be some parsing problems in CMUD with %mapquery():-
Code:
1.
#show %mapquery(Name='The West Road')
Compiles to:
0000   STR   'Name='TheWestRoad''
0028   FUNCREF   mapquery   (1)
0040   CMD   show   (1)
Spaces have been removed from the query.  Note that the documentation says to use single quotes.  Double quotes currently work better...

2.
#show %mapquery(Zoneid=%zonenum() AND Name="The West Road")
Compiles to:
0000   STR   'Zoneid='
0016   FUNCREF   zonenum   (0)
0028   CONCAT   
0032   STR   'ANDName="The West Road"'
0064   CONCAT   
0068   FUNCREF   mapquery   (1)
0080   CMD   show   (1)
Notice there is no space between AND and Name.  Similar results for:
#show %mapquery(Zoneid=%zonenum() AND NOT Name="The West Road")

3.
#show %mapquery(Zoneid=%zonenum() {AND Name="The West Road"})
and even:
#show %mapquery(Zoneid=%zonenum() {AND }Name="The West Road")
Do not compile, with error "unmatched parenthesis".

This one works:
#show %mapquery(Zoneid=%zonenum() "AND "Name="The West Road")


The problem is that %mapquery currently removes whitespace (even stuff in single quotes).

CMUD 2.10 (and CMUD 2.07 and 1.34) on WinXP SP2.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Sat Nov 03, 2007 5:15 pm   
 
That's because %mapquery takes a string argument. The proper syntax in CMUD would be:
Code:
#show %mapquery("Name='The West Road'")

Sorry, but CMUD is just pickier about string values. Outside of quotes (or {}) spaces are stripped. Because %mapquery is still an old mapper function ported from zMUD, it isn't taking an "expression" as the argument, it's still just taking a string value.

Single quotes have no meaning in CMUD at all...it's just another character.
Reply with quote
Iceclaw
Apprentice


Joined: 11 Sep 2005
Posts: 124

PostPosted: Sat Nov 03, 2007 6:24 pm   
 
That explains it. Perhaps the %mapquery() Documentation could be updated to reflect this, with examples of how to make AND work properly (because of the automatic Concat issues)
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat Nov 03, 2007 6:30 pm   
 
Try concating explicitly as I've suggested in the original thread - if that works, I'll change the help.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sat Nov 03, 2007 8:59 pm   
 
Well, {} doesn't work in it either, so {} obviously doesn't always work as a string operator.
Code:
#show %mapquery({Zoneid=123 AND Name='The West Road'})
0000   STR   'Zoneid=123ANDName='TheWestRoad''
0040   VARTYPE   String
0048   FUNCREF   mapquery   (1)
0060   CMD   show   (1)
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat Nov 03, 2007 9:09 pm   
 
I think that's probably more to do with the context that you're using {} in - it's supposed to be used to group arguments to commands, not arguments to functions. An argument to a command is another command (or a number of them), whereas an argument to a function is always some kind of value, so there's a difference.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sat Nov 03, 2007 9:20 pm   
 
I thought {} was supposed to be the same as "", in CMUD, but expand variables and functions?
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat Nov 03, 2007 9:32 pm   
 
Well, you've just proved that that's not true :P I'm assuming based on the facts that all the examples Zugg has given when he's said that have been commands and that it's not working in this case.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Nov 03, 2007 9:36 pm   
 
I know explicit concatenation works through %concat. I use that with %mapquery in my scripts without any problems. From what Zugg is saying I would expect that other functions likely do the same thing. This is the first anyone has mentioned it as a problem.

Unless this suddenly started happening with 2.10 I do not believe it is a bug. Currently all the examples in the help also show the parameter in quotes, and that topic has not been updated in anyway for CMud.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sat Nov 03, 2007 9:55 pm   
 
Hmm, well I did go from the wrong starting point - someone's forum post rather than the manual (and assumed they were following the manual). But I am curious about the issue with braces...
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Sat Nov 03, 2007 10:57 pm   
 
Seb
May be you just had red an arcticle in manual that still uses ' in its samples and when you get to write your script you remember that?
_________________
My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sun Nov 04, 2007 3:11 am   
 
No, I was just extending the code in here, trying to add a second term to the query that Iceclaw already had.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Nov 05, 2007 5:35 pm   
 
Unfortunately {} doesn't work in all cases as string delimiters, especially in old functions that were directly ported from zMUD (like the mapper stuff). And in function calls you need to use " quotes, or use %concat explicitly
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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