Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ how to implement a zmud function "#cap number"

how to implement a zmud function "#cap number"

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Fred   (11 posts)  Bio
Date Mon 16 Jan 2006 06:35 AM (UTC)
Message
I want to capture certain lines after a trigger fired.
such as whenever a trigger is fired, it will send the next 5 lines to notepad. Is there any way to implement it?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 16 Jan 2006 09:48 PM (UTC)
Message
The simplest thing is to make a multi-line trigger, like this:


<triggers>
  <trigger
   enabled="y"
   lines_to_match="6"
   match="^whatever matches first line\n.*\n.*\n.*\n.*\n.*\n\z"
   multi_line="y"
   regexp="y"
   send_to="1"
   sequence="100"
  >
  <send>Your response here</send>
  </trigger>
</triggers>


What this is doing is matching the "trigger text" as the first part of the regular expression, followed by 5 lots of .* (anything) followed by a newline.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fred   (11 posts)  Bio
Date Reply #2 on Tue 17 Jan 2006 01:09 AM (UTC)
Message
thanks,it works
but I still have a question.
actually i want to save those lines into a file.
if i use send to log. seems like it will write to file
after i disconnet.. then i try function to write the %0
into file. it always say something like the string is incomplete...
Any idea?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Tue 17 Jan 2006 03:19 AM (UTC)
Message
Did you quote it? Like: "%0"

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fred   (11 posts)  Bio
Date Reply #4 on Tue 17 Jan 2006 04:10 AM (UTC)
Message
Ya, I did
even Note("%0") doesnt work
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #5 on Tue 17 Jan 2006 04:25 AM (UTC)

Amended on Tue 17 Jan 2006 04:26 AM (UTC) by Nick Gammon

Message
First, you can simplify the trigger like I do below with:


(.*\n){5}


This makes it more obvious that we want exactly five of the extra lines.

Next, in Lua you can have multi-line literals, so this will work:


<triggers>
  <trigger
   enabled="y"
   lines_to_match="6"
   match="^whatever matches first line\n(.*\n){5}\z"
   multi_line="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>Note [[%0]]</send>
  </trigger>
</triggers>


The sequence [[ something ]] is a multi-line literal, which can include linebreaks.

An alternative, if you don't want to use Lua (for some reason hehe), is to call a script, like this (in VBscript):


sub mytrigger (name, line, wildcards)
  Note wildcards (10)
end sub


Now the issue of newlines within a quote goes away as this is a variable, not a quoted string.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fred   (11 posts)  Bio
Date Reply #6 on Tue 17 Jan 2006 04:33 AM (UTC)
Message
cool
thx for your help.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


16,456 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.