mIRC Home    About    Download    Register    News    Help

Print Thread
Why I can't get this to work? #266426 07/12/19 07:02 PM
Joined: Nov 2003
Posts: 82
C
colt45 Offline OP
Babel fish
OP Offline
Babel fish
C
Joined: Nov 2003
Posts: 82
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

Re: Why I can't get this to work? [Re: colt45] #266427 07/12/19 07:20 PM
Joined: Dec 2002
Posts: 2,021
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,021
Try $gettok($1-,1--4,32)

Re: Why I can't get this to work? [Re: RoCk] #266428 07/12/19 07:30 PM
Joined: Nov 2003
Posts: 82
C
colt45 Offline OP
Babel fish
OP Offline
Babel fish
C
Joined: Nov 2003
Posts: 82
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?

Re: Why I can't get this to work? [Re: colt45] #266429 07/12/19 07:40 PM
Joined: Dec 2002
Posts: 2,021
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,021
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)

Re: Why I can't get this to work? [Re: RoCk] #266431 07/12/19 07:46 PM
Joined: Nov 2003
Posts: 82
C
colt45 Offline OP
Babel fish
OP Offline
Babel fish
C
Joined: Nov 2003
Posts: 82
Ahhhhhh gotcha!! laugh
I'll be sure to make note of it for the future.
Many thanks