TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Performing substitutions across multiple lines

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> General Discussion
View previous topic :: View next topic  
Author Message
Kiwi



Joined: 17 Oct 2013
Posts: 6

PostPosted: Thu Oct 17, 2013 2:46 am    Post subject: Performing substitutions across multiple lines Reply with quote

The MUD I am playing can run in a special mode which allows me to customise the output quite extensively via tt++, however one of the ways that it works is frustrating me. When in this mode it surrounds certain object with special hex codes and terminates with a hex FF. When the result all fits on one line i have no problem as I can use #sub HEX CODE %1 FF subbing in what i want. However - the MUD can split the line anywhere within the pattern. TT++ sees each hex 0d0a sequence as the end of a line and the sub fails. How can I build several lines terminated by hex 0d0a into one variable which I could then use #rep on before displaying it and gag the normal line. I imagine using the input prompt character sent by the MUD as the indicator that we have reached the end of the received text.

Any ideas?
Back to top
View user's profile Send private message
Slysven



Joined: 10 Apr 2011
Posts: 365
Location: As "Jomin al'Bara" in WoTMUD or Wiltshire, UK

PostPosted: Sun Nov 03, 2013 6:54 pm    Post subject: Reply with quote

Just passing through - sorry I've been distracted by other projects (Mud clients!) and a bereavement..

Sounds like you need a multi-line capture to grab all the lines, this could be done with a "grab-everything" #ACTION {%0} . Then you use TinTin++ priority system (using number 1 to 9 on trailing end {in position marked '#'} of: #ACTION {} {} {#}) so that the #ACTION to stop capturing has a lower number than the one that captures everything. Importantly in the code below you see that the second #ACTION creates the two further ones needed but because they are nested you need additional %'s as one is stripped off for each level of such nesting. Once you have the (multi-line) stuff in a variable then you can display it with whatever substitutions you like. I'm assuming that there is only one of these hex code bracketed things on a line - if that is not the case then things get a bit more complicated! Also it does not retain the original end of lines for the MUD output which can be put in with '\n's where each captured line is appended to what has already been stored.

Code:
#VARIABLE {startcode} {\xFA}
#VARIABLE {endcode} {\xFF}

#ACTION {%1${startcode}%2${endcode}%3}
{
   #NOP Single line capture, assumes only one capture will ever be required in a line;
   #VARIABLE {beforetext} %1;
   #VARIABLE {capturetext} %2;
   #VARIABLE {aftertext} %3;
   #NOP Do stuff with the stuff in variable capturetext;
   #NOP The before and after stuff are in the other variables...;

...

}{3}

#ACTION {%1${startcode}%2}
{
   #NOP Start of multi-line capture, must have a higher number (= lower priority);
   #NOP than single-line capture action as they both have the startcode but we;
   #NOP want the single-line one to fire if it can.;
   #VARIABLE {beforetext} %1;
   #VARIABLE {capturetext} %2;
   #ACTION {%%1${endcode}%%2}
   {
       #VARIABLE {capture} ${capture}%%1;
       #VARIABLE {aftertext} %%2;
       #NOP End of multi-line capture.  This action turns off the grab every-line;
       #NOP trigger following AND then deletes itself, it has a higher priority;
       #NOP (lower number) than the single line capture which also has the;
       #NOP endcode so it fires in preference, though this action and the grab;
       #NOP everything one do not actually exist in the system until the start;
       #NOP of multi-line capture actually fires!;
       #NOP Process the captured stuff in variable capturetext;
       #NOP The before and after stuff are also in the relevant variables...;

...

       #UNACTION {%%1${endcode}%%2}
   }{2};
   #NOP And here is the (dangerous) grab everything action, it has the lower;
   #NOP priority so the end capture one fires in preference.  It is dangerous;
   #NOP because it swallows everything that the MUD server sends so if all the;
   #NOP incoming stuff disappears from your screen - this is the guilty party!
   #ACTION {%%0}
   {
      #VARIABLE {capturetext} {${capturetext}%%0}
   }{5}
}{4}
Back to top
View user's profile Send private message
Kiwi



Joined: 17 Oct 2013
Posts: 6

PostPosted: Sat Nov 09, 2013 3:46 am    Post subject: Reply with quote

Thx for the tips I will give this a go
Back to top
View user's profile Send private message
Slysven



Joined: 10 Apr 2011
Posts: 365
Location: As "Jomin al'Bara" in WoTMUD or Wiltshire, UK

PostPosted: Tue Nov 26, 2013 10:38 pm    Post subject: Reply with quote

Heck, I've blundered Embarassed - I think I forgot the vital line to turn off the grab everything #ACTION {%0}:
Change the skeleton code:
Code:
#ACTION {%1${startcode}%2}
{
   #NOP Start of multi-line capture, must have a higher number (= lower priority);
   #NOP than single-line capture action as they both have the startcode but we;
   #NOP want the single-line one to fire if it can.;
   #VARIABLE {beforetext} %1;
   #VARIABLE {capturetext} %2;
   #ACTION {%%1${endcode}%%2}
   {
       #VARIABLE {capture} ${capture}%%1;
       #VARIABLE {aftertext} %%2;
       #NOP End of multi-line capture.  This action turns off the grab every-line;
       #NOP trigger following AND then deletes itself, it has a higher priority;
       #NOP (lower number) than the single line capture which also has the;
       #NOP endcode so it fires in preference, though this action and the grab;
       #NOP everything one do not actually exist in the system until the start;
       #NOP of multi-line capture actually fires!;
       #NOP Process the captured stuff in variable capturetext;
       #NOP The before and after stuff are also in the relevant variables...;

...

       #UNACTION {%%1${endcode}%%2}
   }{2};
   #NOP And here is the (dangerous) grab everything action, it has the lower;
   #NOP priority so the end capture one fires in preference.  It is dangerous;
   #NOP because it swallows everything that the MUD server sends so if all the;
   #NOP incoming stuff disappears from your screen - this is the guilty party!
   #ACTION {%%0}
   {
      #VARIABLE {capturetext} {${capturetext}%%0}
   }{5}
}{4}
to
Code:
#ACTION {%1${startcode}%2}
{
   #NOP Start of multi-line capture, must have a higher number (= lower priority);
   #NOP than single-line capture action as they both have the startcode but we;
   #NOP want the single-line one to fire if it can.;
   #VARIABLE {beforetext} %1;
   #VARIABLE {capturetext} %2;
   #ACTION {%%1${endcode}%%2}
   {
Missing line:
Code:
       #UNACTION {%%0};
Code:

       #VARIABLE {capture} ${capture}%%1;
       #VARIABLE {aftertext} %%2;
       #NOP End of multi-line capture.  This action turns off the grab every-line;
       #NOP trigger following AND then deletes itself, it has a higher priority;
       #NOP (lower number) than the single line capture which also has the;
       #NOP endcode so it fires in preference, though this action and the grab;
       #NOP everything one do not actually exist in the system until the start;
       #NOP of multi-line capture actually fires!;
       #NOP Process the captured stuff in variable capturetext;
       #NOP The before and after stuff are also in the relevant variables...;

...

       #UNACTION {%%1${endcode}%%2}
   }{2};
   #NOP And here is the (dangerous) grab everything action, it has the lower;
   #NOP priority so the end capture one fires in preference.  It is dangerous;
   #NOP because it swallows everything that the MUD server sends so if all the;
   #NOP incoming stuff disappears from your screen - this is the guilty party!
   #ACTION {%%0}
   {
      #VARIABLE {capturetext} {${capturetext}%%0}
   }{5}
}{4}
Without that change I think that the dire situation where everything is grabbed and you see nothing back from the server until you can type #UNACTION {%0} manually will happen the first time the start mulit-line capture fires... Use your Head
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> General Discussion All times are GMT - 5 Hours
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
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group