mIRC Home    About    Download    Register    News    Help

Print Thread
get string out of longer string #105620 18/12/04 07:48 PM
Joined: Aug 2004
Posts: 237
L
LethPhaos Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Aug 2004
Posts: 237
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.

Re: get string out of longer string #105621 18/12/04 08:07 PM
Joined: Dec 2002
Posts: 788
C
Coolkill Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
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.

Re: get string out of longer string #105622 18/12/04 08:14 PM
Joined: Aug 2004
Posts: 237
L
LethPhaos Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Aug 2004
Posts: 237
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?

Re: get string out of longer string #105623 18/12/04 08:50 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019

on *:TEXT:*:?: if ($nick == IdleRPG) { tokenize 59 $1- | echo -t $* | close -m $nick }


Gone.
Re: get string out of longer string #105624 18/12/04 09:13 PM
Joined: Aug 2004
Posts: 237
L
LethPhaos Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Aug 2004
Posts: 237
Thanx to both of you!

Re: get string out of longer string #105625 18/12/04 09:29 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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


Gone.
Re: get string out of longer string #105626 19/12/04 02:56 PM
Joined: Aug 2004
Posts: 237
L
LethPhaos Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Aug 2004
Posts: 237
is the on open event only triggered in private messages?

Re: get string out of longer string #105627 19/12/04 03:03 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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


Gone.
Re: get string out of longer string #105628 19/12/04 03:13 PM
Joined: Aug 2004
Posts: 237
L
LethPhaos Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Aug 2004
Posts: 237
Thanks!

Re: get string out of longer string #105629 19/12/04 03:34 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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


Gone.