mIRC Homepage
Posted By: kdogg1 Saving line of chat to a variable - 10/05/11 02:18 AM
Hi All,

Is there a way I can save the last line of text in the chat window to a variable?

I want to then email that to myself (if it contains certain words). But for this question I'd just like to know how to save the line of text to a variable.

Thank you :-)
Posted By: DJ_Sol Re: Saving line of chat to a variable - 10/05/11 05:50 AM
There are a few ways.

$line(@name,N,T)

Returns the Nth line of text in the specified window. If N is zero, it returns the total number of lines in the window.

For some reason I thought /loadbuf took lines from a window and put them in a file. On second look I guess it's the other way around.

Anyways, $line($chan,0) is total number of lines, so $line(#,$line(#,0)) will return the last line in a channel window.

set %var $line(#,$line(#,0))
Posted By: kdogg1 Re: Saving line of chat to a variable - 11/05/11 05:30 AM
Thank you DJ_Sol for your great answer.

I use an on TEXT event. I really want to capture this line of text that the on TEXT event is using. Will capturing the last line be sufficient to capture this?

Would %lineOfText = $1- work inside the on TEXT event? (just thinking, not near a desktop computer atm - only iPhone).

Thanks again.
Posted By: Riamus2 Re: Saving line of chat to a variable - 11/05/11 10:16 AM
Yes, you can use $1- in a text event to capture the text. Keep in mind that the on text event only captures normal text. It does not capture what you say, actions (/me), notices, etc. If you need to capture more than just normal text, you'll need multiple events. As far as the variable goes, if you are using the information immediately, you can use /var %varname = $1- , but if you need to store it for later use, you need to use /set %varname $1- . /var is just a temporary variable for use in the event itself.
© mIRC Discussion Forums