mIRC Homepage
Posted By: LethPhaos get string out of longer string - 18/12/04 07:48 PM
I have this string:
LethPhaos: Level 2 Ugly Dwarf; Status: Online; TTL: 0 days, 00:08:17; Idled: 0 days, 00:26:50; Item sum: 4
and I want my script to echoe the information given in it on different lines.
Therefore I need to get parts of the string out of it. How to do that?
Let's say I need the 'Online' part, how to find it? And how to get it out?
Just $left and $right isn't enough, because the level is not always 1 digit, it could be more.
Posted By: Coolkill Re: get string out of longer string - 18/12/04 08:07 PM
There are two possibilities, depends really on which you prefer, you either use;

tokenize [color:red]59
LethPhaos: Level 2 Ugly Dwarf; Status: Online; TTL: 0 days, 00:08:17; Idled: 0 days, 00:26:50; Item sum: 4
[/color]
and then immediately after you can use, $1, $2, ect, to grab the different sections, seperated by a ';' (character, 59)

or;

var %t = LethPhaos: Level 2 Ugly Dwarf; Status: Online; TTL: 0 days, 00:08:17; Idled: 0 days, 00:26:50; Item sum: 4
echo - $gettok(%t,[color:red]N
,59)
[/color]
replacing N with the section you wish to grab.

iEamonn.
Posted By: LethPhaos Re: get string out of longer string - 18/12/04 08:14 PM
Ok I made this:
on *:text:*:?:{
if ( $nick == IdleRPG ) { tokenize 59 $1- | echo -t $1 | echo -t $2 | echo -t $3 | echo -t $4 | echo -t $5 | close -m $nick }
}
How could I improve the script that it doesn't repeat all the echoes?
Posted By: FiberOPtics Re: get string out of longer string - 18/12/04 08:50 PM

on *:TEXT:*:?: if ($nick == IdleRPG) { tokenize 59 $1- | echo -t $* | close -m $nick }
Posted By: LethPhaos Re: get string out of longer string - 18/12/04 09:13 PM
Thanx to both of you!
Posted By: FiberOPtics Re: get string out of longer string - 18/12/04 09:29 PM
No problem.

You could consider using the on OPEN event instead, and after echoing the info, just putting "halt", so that close -m $nick is obsolete, and the window is never visibly open.

Greets
Posted By: LethPhaos Re: get string out of longer string - 19/12/04 02:56 PM
is the on open event only triggered in private messages?
Posted By: FiberOPtics Re: get string out of longer string - 19/12/04 03:03 PM
on OPEN/CLOSE

The on OPEN and on CLOSE events trigger for various events relating to the opening and closing of a window of different types of windows. In the case of dcc sessions, they trigger when a dcc connection has opened or closed.

Format: on <level>:OPEN|CLOSE:<?|@|=|!|*>:<matchtext>:<commands>

If you specify the question mark, then yes it will only trigger for the opening of query windows.

Greets
Posted By: LethPhaos Re: get string out of longer string - 19/12/04 03:13 PM
Thanks!
Posted By: FiberOPtics Re: get string out of longer string - 19/12/04 03:34 PM
No problem.

That came straight from the help file actually, /help on open

Might want to check out the help file from time to time, it's a pool of knowledge just waiting for you to swim in grin

Greets
© mIRC Discussion Forums