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
neep
Beginner


Joined: 23 Apr 2003
Posts: 12
Location: USA

PostPosted: Thu May 22, 2003 10:18 pm   

problems w/ special chars in a variable
 
Zugg helped me w/ the main part of the problem I was having w/ special chars, he told me about using %expand(@varname, 1) instead of just using @varname and it doensn't expand anything within the variable. I'm still having problems though. Heres all the details: sorry for the length but it's necessary so you get all the details.

I have an id script I'm working on that takes the stats of an item and adds the item to a database if it's new or if the stats do not match the stats of the item already in the database (to take into account upped/downed or mended eq) The problem is w/ eq that has special chars in it which are (){}[],;%#@&" and any other's I'm not thinking of. W/ zugg's help I have it working properly for most items, heres what I'm doing..

To make it simpler, I'll just show you a trig I set up to test whether it's working or not, heres the first version, this works w/ strip quotes turned on in prefs
#TRIG {Neep says '(%*)'} {neepsays="%1";say %expand(@neepsays,1)}
This works for everything unless neep says something like [test "test" stuff] (w/o the []), in which case the " would be removed for some reason. And if there is only one quote, then it doesn't work at all. So far this is the most functional way to do it, where it seems to work for every case except eq with "

I've tried using neepsays=%literal(%1) but that doesn't work if there are , or { in it and probably doesn't work for other cases as well.

I've tried turning off striping quotes, but then I can't figure out a way to set @neepsays=%1 because as I've said %literal() doesn't work, %quote() doesn't work, I've even tried using #VAR neepsays {%1} but that doesn't work either.

Usually the problem is when there are , in it, that causes it to mess up whenever you use neepsays=%func(%1) (where func can be literal, expand, or whatever) because it thinks the , is saying that the next part of the funcion is after the comma, so the only way that works the best is neepsays="%1" Ok I'm being a little redundant... I'm probably leaving out a few details so tell me if you need more. Oh yeah, if you just use @neepsays=%1 then it sets @neepsays= to everything in the rest of the trig, so @neepsays would equal ';say %expand(%1,1)

Thanks for any help.

-Neep
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri May 23, 2003 11:18 am   
 
The way in which %1 is expanded never got documented well in the help. %1..%99 and %i..%z are expanded early. This means that when the script is transfered to the parser those values are filled in, then the parser starts. The correct way to capture special character is therefore with either a direct assignment trigger pattern, or using the %param function in the script.

#TR {Neep says '&%*{neepsays}'} {neepsaid=%expand(%param(1),1)}
Reply with quote
neep
Beginner


Joined: 23 Apr 2003
Posts: 12
Location: USA

PostPosted: Fri May 23, 2003 7:05 pm   
 
Wow, this work perfectly! It works w/o the neepsaid=%expand(%param(1),1) part, all I have to do is...
#TR {Neep says '&%*{neepsays}'} {say %expand(@neepsays,1)}

And he says everything that I can think to throw at him as far as special chars and colors go. It even fixed a bug I forgot to mention where a certain sequence of special chars combined w/ colors was messing it up, to where instead of the end part of the name being a black #] it was something like # then an unprintable ascii... anyways thanks a whole bunch Vijilante, I had no idea how to do this since like you said it's not documented very well. And thanks to zugg again for telling me about %expand(@varname,1) (in case your wondering I originally sent my problem through the wrong channels and it ended up in zugg's e-mail, and he responded.. I'm really getting my money's worth having the creator help me (even if it was by accident))

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