mIRC Homepage
Posted By: colt45 Why I can't get this to work? - 07/12/19 07:02 PM
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
Posted By: RoCk Re: Why I can't get this to work? - 07/12/19 07:20 PM
Try $gettok($1-,1--4,32)
Posted By: colt45 Re: Why I can't get this to work? - 07/12/19 07:30 PM
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?
Posted By: RoCk Re: Why I can't get this to work? - 07/12/19 07:40 PM
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)
Posted By: colt45 Re: Why I can't get this to work? - 07/12/19 07:46 PM
Ahhhhhh gotcha!! laugh
I'll be sure to make note of it for the future.
Many thanks
© mIRC Discussion Forums