mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
Example, The quick brown fox jumps over the lazy dog

If I do this

var %line $1-
$count(%line,$chr(32))
echo @Result Final Result: $1-6


The output would show: The quick brown fox jumps over

BUT - Not all lines are the same, I just want to get rid of the last 3 words from the end (they're all randoms but always 3 words)

Then if I do this which I thought might work but it doesn't seem to do it.

var %line $1-
var %word $calc($count(%line,$chr(32))-3)
echo @Result Final Result: $1- $+ %word


It shows error i.e. The quick brown fox jumps over the lazy dog9

Help me understand a bit more mIRC scripting? - This is annoyning cos I thought I did it correctly but keeps coming out wrong over and over again frown

Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031
Try $gettok($1-,1--4,32)

Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
Nice, that works! laugh
Gonna see how it goes for the next few more lines.

I get that $1 and 32 but any chance of a simple explanation what's 1--4 does so that I can have a better understanding next time?

Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031
If you use: $gettok(The quick brown fox jumps over the lazy dog,1-,32)

You get: The quick brown fox jumps over the lazy dog

The 1- is returning all tokens starting from the 1st through the last.

If you use: $gettok(The quick brown fox jumps over the lazy dog,2-5,32)

You get: quick brown fox jumps

The 2-5 is returning all tokens from the 2nd through the 5th.

If you use: $gettok(The quick brown fox jumps over the lazy dog,1--4,32)

You get: The quick brown fox jumps over

The 1--4 is returning all tokens starting from the 1st through the 4th from the last. (IE All but the last 3 tokens)

Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
Ahhhhhh gotcha!! laugh
I'll be sure to make note of it for the future.
Many thanks


Link Copied to Clipboard