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
Fizgar
Magician


Joined: 07 Feb 2002
Posts: 333
Location: Central Virginia

PostPosted: Thu Oct 07, 2010 6:30 am   

[3.30] %quote() not quoting $ and @ characters.
 
This mud I'm on right now uses $ for prompt variables. While adding an alias to switch prompts depending on what I am doing I noticed this. Rather than going through and quoting out each $ one by one I figured I would use %quote().

Code:
#show {~$h}

quotes the $ and displays
Code:
$h

to the screen just like that.

Code:
#show {%quote($h)}

That returns an error pop up saying that h is an invalid local variable.

The help file for %quote states
Quote:
Returns the string s with any special characters quoted with the current quote character

I guess since there is no option to change the special character for local variables in preferences the $ is not considered a special character?

However, if I type:
Code:
#show {%quote(@H)}

on the command only a blank line is displayed rather than @H being displayed as if i had typed
Code:
#show {~@H}


Unless I am misunderstanding the use of %quote() this seems buggy.

On a side note. In the help file for %quote() there is a link to a page for special characters that when clicked points to a non existent help article.
_________________
Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Oct 07, 2010 1:02 pm   
 
It would seem to me that %quote takes variable arguments and is working as intended, however if you used %quote("$h") I imagine it would work just fine.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Fizgar
Magician


Joined: 07 Feb 2002
Posts: 333
Location: Central Virginia

PostPosted: Thu Oct 07, 2010 2:06 pm   
 
Ok from the Conversion help topic.

Code:
%quote(s)
Returns string s with any special characters escaped with quote character

I still say something is messed up here.

Code:
#show {%quote(@H)}

The above command does not show @H but rather a blank line so the quote function obviously isn't escaping the @ as the help file says it should.

Perhaps once the %quote() function is corrected the issue with $ will be resolved too.

*edit*
Hit submit rather than preview. :( Yeah #show {"$H"} works, but the point of the post was to report the bug with %quote so if it wasn't on the list it could be added.
_________________
Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Thu Oct 07, 2010 2:48 pm   
 
I just tried this in zMUD and it's works the same way. The %quote function can take a variable input, and when received will quote the contents of said variable.

Without the quotes, around @H or $j, CMUD necessarily interpret as a variable and not a string.
_________________
Asati di tempari!
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Oct 07, 2010 8:33 pm   
 
Code:

<alias name="test_q" id="162">
  <value>$h="This is $h"
#show {Test 1 $h}
#show {Test 2 %quote($h)}
#show {Test 3 %quote("$h")}</value>
</alias>


Is %quote supposed to surround it in quotes? I'm not noticing any issues other than that, seems to be working just fine. As Tech said, and I mentioned earlier, %quote expands variables in its parameters. This means that $h is being seen as a local variable and it's attempting to expand it, this works with @h too. If a variable like @h doesn't exist or has a null value, it will feed a blank line in return. In order to get just $h you need to make it a string and surround it in quotes.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Oct 07, 2010 10:51 pm   
 
Quote:

Is %quote supposed to surround it in quotes? I'm not noticing any issues other than that, seems to be working just fine.


%quote() does not surround the parameter with quotes, and probably doesn't return a result of "result", with the " displayed. However, if the parameter passed includes a " then %quote() should be doing the necessary steps to make each " show up. If I recall, the result would be something like ""result"".

Anywho, I don't think ANY function will adjust the data passed to it in such a way as to "fix" typos, so even functions like %literal() that don't allow variable expansion will probably cause the parser to cry foul.

Finally, if this is on the command line, you can use ~ or ` at the beginning to prevent CMud from parsing the line which should allow you to do the prompt command using just $h rather than "$h".
_________________
EDIT: I didn't like my old signature
Reply with quote
Fizgar
Magician


Joined: 07 Feb 2002
Posts: 333
Location: Central Virginia

PostPosted: Fri Oct 08, 2010 5:19 am   
 
Ok, so %quote(s) where s can be a variable. It should probably be added to the help file that if s is a variable it will be expanded.

Even so, how come the following returns:
Code:
A expanded B expanded C expanded

rather than:
Code:
@A @B @C


Code:

<class name="test" id="33">
  <alias name="test" id="29">
    <value>$test1 = @A @B @C

#show {%quote($test1)}</value>
  </alias>
  <var name="a" id="30">A expanded</var>
  <var name="b" id="31">B expanded</var>
  <var name="c" id="32">C expanded</var>
</class>
_________________
Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2307

PostPosted: Fri Oct 08, 2010 2:48 pm   
 
Because that is what %quote does. It is what every function does when the argument is a variable. This is not odd at all. %quote("@A @B @C") does what you expect. Without the quotation marks, it treats those as variables to be expanded before applying the function.
Reply with quote
Fizgar
Magician


Joined: 07 Feb 2002
Posts: 333
Location: Central Virginia

PostPosted: Fri Oct 08, 2010 3:37 pm   
 
I see now. Thanks for all the feedback that helped me gain a slightly better understanding of how things work. Sorry it took so long to get it through my thick skull.
_________________
Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Oct 14, 2010 6:35 pm   
 
Also, just to add that $ isn't handled by %quote by default since $ isn't technical a "special character" (cannot be edited in the Special Characters preferences). But using the second optional argument to %quote you can add $ to the list of characters that are quoted.
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