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


Joined: 25 Jan 2002
Posts: 2

PostPosted: Fri Jan 25, 2002 9:06 pm   

pattern matching question
 
I have text coming in that looks like: 008ABCDEFGH

The first 3 characters (008) tell how many characters are left in the line.

Originally, I tried to use (&03)(%*) as the pattern. The problem with that is that the line doesn't necessarily end there. The line doesn't have a CRLF at the end.

For example: 008ABCDEFGH003ABC

I want to make a pattern like (&03)(&%1). The idea is I want to put the number from the first parameter into the second paramater and read that many digits. But the syntax above doesn't work.

Any ideas?
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Sat Jan 26, 2002 4:43 am   
 
If you are getting (pattern)(pattern)..

Then the way that I've found that works the
best is to grab the entire line then parse
it out.

Off the top of my head here is something
which you might consider:



Trigger: ^(%*)$
ie 008ABCDEFGH003ABC..
When should this trigger be on? Always
or just when you are to receive such
sequences..
Script:
#VAR ToParse %1
#WHILE (
@ToParse( <> "") {
#NOOP Is that while statement correct?
#NOOP will the copy make it go to ""?
#VAR SequenceSize
%copy(@ToParse,1,3)
#VAR Sequence
%copy(@ToParse,3,@SequenceSize)
#VAR Parsed
%additem(@Sequence)
#VAR ToParse
%copy(@ToParse,[3+@SequenceSize],%len(@ToParse))
}


TonDiening
Uses 6.16
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