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


Joined: 21 Jan 2002
Posts: 7
Location: Canada

PostPosted: Sun Feb 03, 2002 6:45 pm   

Special characters in strings
 
I've run into a problem inserting special characters (more specifically "<" and ">") into strings in Zmud. What I'm trying to do is capture lines of text, and insert an HTML "<br>" at the end of each line (the text is being stored in a MySQL DB). Right now my trigger looks like this:

#TRIGGER {^(*)$} {@Buffer = %concat( @Buffer, "<br>", "%1")}

(there is a seperate trigger that turns it off)

The problem is that the resulting string will not contain the whole tag, just the "br". I've tried escaping it (eg. "~<br~>") with no sucess. Any help would be greatly appreciated. Thanks.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Feb 04, 2002 5:41 am   
 
quote:

I've run into a problem inserting special characters (more specifically "<" and ">") into strings in Zmud. What I'm trying to do is capture lines of text, and insert an HTML "<br>" at the end of each line (the text is being stored in a MySQL DB). Right now my trigger looks like this:

#TRIGGER {^(*)$} {@Buffer = %concat( @Buffer, "<br>", "%1")}

(there is a seperate trigger that turns it off)

The problem is that the resulting string will not contain the whole tag, just the "br". I've tried escaping it (eg. "~<br~>") with no sucess. Any help would be greatly appreciated. Thanks.



First off, ZMud uses < and > to denote MXP (basically a subset of HTML, designed for MUDs). That's why it's getting parsed out. Not sure if this will work, but if you are not using MXP you can simply turn it off and ZMud should then stop stripping these characters.

The proper way to do this, though, is probably to use a function like %expand() to control what gets parsed and what doesn't.

li'l shmoe of Dragon's Gate MUD
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Mon Feb 04, 2002 6:18 am   
 
Perhaps try as well:

Syntax: %literal(s)

returns the parameters untouched by expansion or evaluation

TonDiening
Uses 6.16
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon Feb 04, 2002 6:46 am   
 
You could also just concatenate directly instead of relying on a function to do it. Another thing, don't include the @ prefix when creating a variable.

#TRIGGER {^(*)$} {Buffer = ~<br~>"%1"}

LightBulb
All scripts untested unless otherwise noted
Reply with quote
trak
Newbie


Joined: 21 Jan 2002
Posts: 7
Location: Canada

PostPosted: Mon Feb 04, 2002 6:53 am   
 
quote:
First off, ZMud uses < and > to denote MXP (basically a subset of HTML, designed for MUDs). That's why it's getting parsed out. Not sure if this will work, but if you are not using MXP you can simply turn it off and ZMud should then stop stripping these characters.


Disabling MXP doesn't solve the problem, but disabling forced variable expansion does. Although disabling it does work, it would make sense (and I could be completely wrong) that there should be a way to escape the characters. It just doesn't seem clean enough

quote:
The proper way to do this, though, is probably to use a function like %expand() to control what gets parsed and what doesn't.


%expand() also doesn't seem to make a difference. When the characters are stored in a string, they seem to behave differently then when as constant strings in a simple command.

eg)
#echo "<br>"
Output:
<br>

@TempString = "<br>"
#echo @TempString
Output:
br

The problem is that the "<br>" has to be stored in a string, so that it can be passed to a database via my plugin. And since it is stored in a string, %literal(@string) just returns @string (not expanded).

I'm stumped, but turning off forced variable expansion seems to be a decent workaround. However if there is a way to escape the characters, I'd like to know (*wink at Zugg*). Thanks
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Mon Feb 04, 2002 9:02 am   
 
@TempString = "<br>"
#echo %expand(@TempString,1)

works fine for me.

 - Charbal
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