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
Zhiroc
Adept


Joined: 04 Feb 2005
Posts: 246

PostPosted: Sun Aug 21, 2005 6:29 pm   

%literal() bug
 
I think this is a bug, or if not, it is an inconvenience:

#SHOW %literal( this is a, string with a comma)
this is a

#SHOW %literal( "this is a, string with a comma")
"this is a, string with a comma"

So, to make sure the text you get is what you want, you have to do:

#SHOW %subregex( %literal( "this is a, string with a comma"), "^\"|\"$", "")
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Aug 21, 2005 7:28 pm   
 
Have you tried messing with the Strip Quotes preference? I know it works on variables.
_________________
EDIT: I didn't like my old signature
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Aug 21, 2005 8:35 pm   
 
This is actually a very obscure bug in every other function; %literal, %clip, and %quote are the ones that it is most often found in. It is essentially never noticed because internally zMud supplys proper double quotes when retrieving data from a variable. What happens is the comma is taken as a delimeter between parameters if quotes aren't used. I only class this as a bug because all functions are designed to only have a limited number of parameters, therefore I don't think the parser should even try to seperate off other parameters beyond the last that the function expects.

If you are using a text constant there is no real need to use the %literal function, and further more you should use the proper delimeters. While I would class it a bug, it has been around at least as long as I have. You are probably only the third person to ever find it. So I don't expect it to be fixed ever.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Zhiroc
Adept


Joined: 04 Feb 2005
Posts: 246

PostPosted: Sun Aug 21, 2005 9:38 pm   
 
I used a text literal as an example, the real usage is:

#ALIAS t {#IF (%numitems( "%1") = 1 & %numwords( "%1", ",") = 1) {#IF ("%1" = everyone) {mp/h %subregex( %literal( "%-2"), "^\"|\"$", "")} {page %1=%subregex( %literal( "%-2"), "^\"|\"$", "")}} {mp %expandlist( "%1", ",")=%subregex( %literal( "%-2"), "^\"|\"$", "")}}

This is a MUSH generic "page" (i.e. tell/whisper) alias and uses the correct form based on who is being paged. The %literal was the only way I could find to preserve double quotes without other bad effects.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Aug 22, 2005 7:56 am   
 
You might want to use #ONINPUT and directly assign the text to a variable.
#ONINPUT {^t (%x) &Page$} {Page=%quote(@Page);#IF (%numitems( "%1") = 1 & %numwords( "%1", ",") = 1) {#IF ("%1" = everyone) {mp/h %subregex( @Page, "^\"|\"$", "")} {page %1=%subregex( @Page, "^\"|\"$", "")}} {mp %expandlist( "%1", ",")=%subregex( @Page, "^\"|\"$", "")}}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Zhiroc
Adept


Joined: 04 Feb 2005
Posts: 246

PostPosted: Mon Aug 22, 2005 7:05 pm   
 
With the test trigger:

#ONINPUT {^foo (%x) &tmp1$} {page %1=%quote( @tmp1)}

and input:

foo target testing "with quotes" @foo and ats and %S percents

The result is:

page target=testing "with quotes" ~@foo and ats and ~%S percents

Not sure why the quoting tildes remain in the text for the ats and percents, but not for the quotes.
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