mIRC Home    About    Download    Register    News    Help

Print Thread
#147557 20/04/06 03:03 PM
Joined: May 2005
Posts: 35
N
nutt3 Offline OP
Ameglian cow
OP Offline
Ameglian cow
N
Joined: May 2005
Posts: 35
Erm not sure if i can explain this but ill try smile

i wanna read a line, and replace 3th LAST erm 'thing' soo i need to find out whats 3th last on any given line, soo if a line looks like this:

111 22 333 4444 55 666 777 888

then 111 will be $1 etc and 3th last is 666 $6 but since contents will not be same in next line i need a 'counter' or something that can tell total nunbers of $'s and that way round get to 3th last..

did that make sence?

#147558 20/04/06 03:21 PM
Joined: May 2005
Posts: 449
Fjord artisan
Offline
Fjord artisan
Joined: May 2005
Posts: 449
I'm not sure exactly what you want or where you're getting the line, but look at $numtok. That will tell you how many "words" are in the line. Here's an example, and hopefully you can use it where you need it. I don't know if you want this for an on TEXT event, or in an alias reading from a text file.
Code:
alias wordcount {
echo -a $numtok($1-,32)
}

*usage:
/wordcount This is a sentence.

This would echo "4", since there are four words separated by spaces (ASCII character 32) in that sentence. Look at /help Token Identifiers for help on replacing tokens or getting a specific token in text.

#147559 20/04/06 03:46 PM
Joined: May 2005
Posts: 35
N
nutt3 Offline OP
Ameglian cow
OP Offline
Ameglian cow
N
Joined: May 2005
Posts: 35
thx that does it..

Is there a way to do $2-$(3thlast) ?

#147560 20/04/06 03:52 PM
Joined: Nov 2004
Posts: 842
Hoopy frood
Offline
Hoopy frood
Joined: Nov 2004
Posts: 842
either

$2 $3-

or $2-$3-


What do you do at the end of the world? Are you busy? Will you save us?
#147561 20/04/06 04:00 PM
Joined: May 2005
Posts: 449
Fjord artisan
Offline
Fjord artisan
Joined: May 2005
Posts: 449
Code:
echo -a $gettok($1-,2 - $calc($numtok($1-,32) - 3),32)

#147562 20/04/06 04:02 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
$($+($,2-,$calc($0 - 2)),2)

the red part is 3 - 1, ie you need to subtract 1. So if you wanted to end in the 5th from the last, the red part would be 4.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#147563 20/04/06 04:19 PM
Joined: May 2005
Posts: 35
N
nutt3 Offline OP
Ameglian cow
OP Offline
Ameglian cow
N
Joined: May 2005
Posts: 35
thx alot, thnk im covered now smile


Link Copied to Clipboard