|
Coilean Newbie
Joined: 10 Feb 2003 Posts: 2
|
Posted: Mon Feb 10, 2003 11:44 pm
Help with " appearing in a text string |
Using some code to parse thoughts in Gemstone III, I use the following TRIGGER and COND to capture the full thought, and move it to a window named thought (this code was given by someone else on these forums)
#tr {^You hear the (%w) thoughts of (%w) echo in your mind:} {
#gag
name = %2
thinksas = %1}
#cond {"(*)"} {
#gag
#win Thought {@name ~[@thinksas~]~: %1}
} "" {within|Param=1}
This takes
You hear the faint thoughts of SomeGuy echo in your mind:
"Hey! How's it going!"
and makes it:
SomeGuy: Hey! How's it going!
Problem is that if Someguy puts a quote at the beginning of his thought (a problem because the syntax to talk is a single or double quote at the beginning of the line, so many people carry thi sover into thoughts) then all that shows up in the thought window is:
{Someguy
Presumably because the #win command chokes on having a random " appear in the middle of it's input stream.
Anyone know how to get a string to ~ out the special characters automatically?
Coilean |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Mon Feb 10, 2003 11:54 pm |
Have a look at:
quote:
stripq
Syntax: %stripq(s)
Removes the internal quotes from the string s. This is provided for backwards compatibility with older versions of zMUD. In older versions, internal quotes passed to functions were automatically removed. In newer versions, only the outside quotes are removed. The %stripq function can be used to emulate the behavior of older versions of zMUD.
You can also make a #FUNC variable to strip things.
#FUNC StringConverter {%replace(%replace("%1","~",""),",","")}
Ton Diening |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Tue Feb 11, 2003 12:02 am |
First tighten your condition pattern to {^~"&%*{Thought}~"$}. I know the tildes may not be needed, but they don't hurt and may save you a headache in the future. I also changed the pattern to match all special characters. While such a match isis dangerous, this is the safest way to do it. By having zMud put it directly into the variable you can precisely control when and how much it is expanded.
Now your WIN line becomes:
#win Thought {@name ~[@thinksas~]~: %expand(@Thought,1)}
The %expand may not be needed in newer versions, a quick test was indicating Zugg made some improvements in parsing to protect against special characters in a variable, and never told anyone. |
|
|
|
|
|
|
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
|
|