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
HariKari
Wanderer


Joined: 16 Feb 2001
Posts: 57

PostPosted: Thu Feb 07, 2002 3:12 am   

Using the %* pattern
 
Is there any way to match a pattern that can include the special symbols and then save that to a variable? And also to save to the variable starting spaces.

Heres a trigger similar to what I'm looking for.
#TRIGGER {^(%*)$(%*)$} {#va line1 %1;#va line2 %2}

Test pattern:
ABC 123@=XYZ
ABC~~~@@%$#@

line1: ABC
line2: ABC~@@
Is there a wildcard that can accept every single character because it seems like %* has trouble reading in spaces.

Well.. right now after some more testing, it seems like the special characters do record correctly. I'll have to look a bit more to see why it wasn't working earlier, but the spaces still aren't read in.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Feb 07, 2002 4:12 am   
 
The spaces not being recorded exactly are actually do to the improper use of the var command. Standard warnings about using %* are that you shouldn't unless you completely encapsulate the %x variable, and even then you may have problems. Also %1 should always be inside a set of "s. So here is what would be much better...
#TR {^(%*)$} {Line2=@Line1;Line1=%trigger}
Next best is
#TR {^&%*{Line2}$&%*{Line1}$} {}
And the last option in my book would be.
#TR {^(%*)$(%*)$} {#VA Line2 {%1};#VA Line1 {%2}}

Note I reversed line1 and line2 from your example, this was mainly to match what i think would be best, and also matches the predefined variables %line, %line2, %line3, %line4, and %line5.
Reply with quote
HariKari
Wanderer


Joined: 16 Feb 2001
Posts: 57

PostPosted: Thu Feb 07, 2002 5:42 am   
 
Maybe my example was too generalized hehe ;)

What if you're looking for a certain character... @

09824#$FLKJDF:
WEFOIJ#(*@&$*%
"$(FM$#85#*()"

The "@" will never be on the edge of a line, so the trigger that I had was..
#TRIGGER {^(%*)$(%*)~@(%*)$(%*)$} {#va line1 {%1};#va line2 {%2@%3};#va line3 {%4)}

Hmmm... I guess it would have been easier to just do #va line1 %line3;#va line2 %line2;#va line3 %line1


I've figured out that what was causing me problems earlier, and it is the lines that were being read in that had " on both sides like line3 of my sample. I want to find a certain character in a specific position of the line, so I use rightback/left, but because there are "s, the positioning is messed up because the "s get stripped when put into the function. Is there a way to get the n'th character of a string without having to worry if there are "s or not?
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Thu Feb 07, 2002 6:09 pm   
 
Have you tried using %literal(%1) instead of %1?

 - Charbal
Reply with quote
HariKari
Wanderer


Joined: 16 Feb 2001
Posts: 57

PostPosted: Fri Feb 08, 2002 1:02 am   
 
Last time I checked with %literal.. it gave me exactly what I put in there.

IE: %literal(%1) -> %1
Reply with quote
HariKari
Wanderer


Joined: 16 Feb 2001
Posts: 57

PostPosted: Fri Feb 08, 2002 3:55 am   
 
I have figured out what was wrong with my triggers.

After reading in the line (now using the %line, %line2, %line3), I replace special characters such as " and @ with a different character that is acceptable by the functions.

Earlier when I tried replace, I did not use ~ to show that the character should be used as is.

IE...
Wrong: %replace(%line,",A)
Right: %replace(%line,~",A)

So far the triggers have been working fine with only " and @ being replaced. If anyone can think of any other characters that can cause trouble when being passed into a function, post it here or I'll just find out later if I ever run into that situation.
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