Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
blarg
Beginner


Joined: 14 Jul 2015
Posts: 15

PostPosted: Tue Jul 14, 2015 9:18 pm   

Help with capturing and parsing a msdp variable
 
First of all, I'm a novice. I have a lot of msdp-related stuff working on cmud, but there's one that's giving me a lot of problems.
One of the msdp variables coming in contains multiple lines and I'd like to write it to a window. Here's a basic look at the type of thing that's coming in:

Code:

\n\r( )==========================================================================( )\n\r
 |                                                                            |\n\r
 |                                                                            |\n\r
 |                                                                            |\n\r
 |                                                                            |\n\r
( )--------------------------------------------------------------------------( )\n\r


The number of lines sometimes changes, but I can't get it to work even in a scenario where the lines is constantly 18. I've tried a few different things, with the pattern as SCROLL (.*) and the one in the code below. There's probably a much better way to go about it. Any help would be appreciated.
Code:
<trigger type="Telnet" param="69" priority="14520" regex="true" newline="false" prompt="true" enabled="false" id="506">
  <pattern>SCROLL(.*)[\n\r]+(.*)[\n\r]+(.*)[\n\r]+(.*)[\n\r]+(.*)[\n\r]+(.*)[\n\r]+(.*)[\n\r]+(.*)[\n\r]+(.*)[\n\r]+(.*)[\n\r]+(.*)[\n\r]+(.*)[\n\r]+(.*)[\n\r]+(.*)[\n\r]+(.*)[\n\r]+(.*)[\n\r]+(.*)[\n\r]+(.*)[\n\r]</pattern>
  <value>parseddesc.1 = %1
parseddesc.2 = %2
parseddesc.3 = %3
parseddesc.4 = %4
parseddesc.5 = %5
parseddesc.6 = %6
parseddesc.7 = %7
parseddesc.8 = %8
parseddesc.9 = %9
parseddesc.10 = %10
parseddesc.11 = %11
parseddesc.12 = %12
parseddesc.13 = %13
parseddesc.14 = %14
parseddesc.15 = %15
parseddesc.16 = %16
parseddesc.17 = %17
parseddesc.18 = %18

#clr scroll

#window scroll {%crlf @parseddesc.1 %crlf @parseddesc.2 %crlf @parseddesc.3 %crlf @parseddesc.4 %crlf @parseddesc.5 %crlf @parseddesc.6 %crlf @parseddesc.7 %crlf @parseddesc.8 %crlf @parseddesc.9 %crlf @parseddesc.10 %crlf @parseddesc.11 %crlf @parseddesc.12 %crlf @parseddesc.13 %crlf @parseddesc.14 @parseddesc.15 %crlf @parseddesc.16 %crlf @parseddesc.17 %crlf @parseddesc.18}</value>
</trigger>
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4671
Location: Pensacola, FL, USA

PostPosted: Tue Jul 14, 2015 10:08 pm   
 
You could make use of a #STWIN object to hold the data, which is displayed in the status window.
_________________
Discord: Shalimarwildcat
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Jul 14, 2015 10:08 pm   
 
This should work, but I didn't test the subregex.
Code:
<trigger type="Telnet" param="69" priority="14520" regex="true" newline="false" prompt="true" enabled="false" id="506">
  <pattern>SCROLL(.*)</pattern>
  <value>parsedesc=%subregex(%1,"([^\n\r]*)(?:(\n\r)|\Z)","""\1""(?(2)\|)")
#CLR scroll
#WINDOW scroll {%1}</value>
</trigger>
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
blarg
Beginner


Joined: 14 Jul 2015
Posts: 15

PostPosted: Tue Jul 14, 2015 10:52 pm   
 
Thanks for the quick replies. I tried the xml trigger, but all I get in the window and assigned to parsedesc is an upsidedown L in quotes
Reply with quote
blarg
Beginner


Joined: 14 Jul 2015
Posts: 15

PostPosted: Thu Jul 16, 2015 8:53 pm   
 
I had the mud remove the leading \n\r from the variable so it's coming in like this:


Code:
( )==========================================================================( )\n\r
 |                                                                            |\n\r
 |                                                                            |\n\r
 |                                                                            |\n\r
 |                                                                            |\n\r
( )--------------------------------------------------------------------------( )\n\r



now I get this assigned to the parsedesc variable, but there's a character that looks like an upside down L at the beginning of the line:

Code:
"( )==========================================================================( )"

It looks like it's still not handling the \n\r that are coming in properly. Any ideas?
Reply with quote
blarg
Beginner


Joined: 14 Jul 2015
Posts: 15

PostPosted: Sun Jul 19, 2015 9:15 pm   
 
By the way, I tried holding the data with #STWIN like shalimar suggested, but no dice. It seems like a really simple problem and I just can't figure it out.

I also tried modifying what Vijilante suggested but nothing I try works.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Jul 20, 2015 3:24 am   
 
In order to figure this out you will have to try simpler and simpler things. Let's start with this:
Code:
<trigger type="Telnet" param="69" priority="14520" regex="true" newline="false" prompt="true" enabled="false" id="506">
  <pattern>SCROLL(.*)</pattern>
  <value>parsedesc=%1
#CLR scroll
#WINDOW scroll {%1}</value>
</trigger>
Does that put that correct information into the window and into the variable? Can you use the #DEBUGFILE command to capture the data packets containing the data you want to parse? It would help me to clearly see the data that comes in and might allow me to test different triggers.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
blarg
Beginner


Joined: 14 Jul 2015
Posts: 15

PostPosted: Mon Jul 20, 2015 5:02 am   
 
I'm just getting the upside L in the window and assigned to parsedesc but I'm getting something that looks nicer in #DEBUGFILE

Code:
07/19/15 18:59:30:029 : <IAC><SB><69><1>SCROLL<2><LF><CR>
( )==========================================================================( )<LF><CR>
 |                                                                            |<LF><CR>
 |                                                                            |<LF><CR>
 |       -                  -                   -                  -          |<LF><CR>
 |                                                                            |<LF><CR>
 |                                                                            |<LF><CR>
( )--------------------------------------------------------------------------( )<LF><CR>
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Mon Jul 20, 2015 11:05 am   
 
I'm guessing that the character you're seeing in the window is the ASCII control character <2>, and the reason you haven't been seeing the other lines is because . doesn't match newlines by default. Try this perhaps?

Code:
<trigger type="Telnet" param="69" priority="14520" regex="true" newline="false" prompt="true" enabled="false" id="506">
  <pattern>(?s)SCROLL\x02(.*)</pattern>
  <value>parsedesc=%1
#CLR scroll
#WINDOW scroll {%1}</value>
</trigger>
Reply with quote
blarg
Beginner


Joined: 14 Jul 2015
Posts: 15

PostPosted: Mon Jul 20, 2015 6:49 pm   
 
That's exactly what I needed, Daern. Thank you. It's working perfectly now.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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