mIRC Homepage
Posted By: Wims $istok behavior ? - 20/11/07 10:14 PM
If a $istok has 4 parameters, mIRC don't returns any error and if the third parameters isn't a number, the $istok always returns $true, (tested on 6.31,6.3,6.21 and 6.16)
This can be really annoying in some case.

Some exemple :
Code:
//echo -a $istok(1,2,3,4) return $false
//echo -a $istok(1,2,987361234,3) retun $false
//echo -a $istok(1,2,n,4) return $true
I think all of the exemple should return * Too many parameters: $istok smile
Posted By: jaytea Re: $istok behavior ? - 21/11/07 03:07 AM
check this out!

Code:
//echo -a $istok(.,.,1a,.) - $istok(.,.,2a,.)


=> $true - $false

:S

Posted By: Wims Re: $istok behavior ? - 21/11/07 02:32 PM
Lol, very odd.
I can't explain this because with 2 or 5 parameters, mirc return an error.
Posted By: RoCk Re: $istok behavior ? - 21/11/07 02:34 PM

Odd as all of the results are, it seems to me that when used correctly, it seems to work correctly.

confused
Posted By: Trashlord_ Re: $istok behavior ? - 21/11/07 02:56 PM
It should still return an error message whenever it's used incorrectly, just in case someone who isn't very familier with it, knows it doesn't work for them because they're using it wrong.
Posted By: Mpdreamz Re: $istok behavior ? - 21/11/07 03:35 PM
*Mpdreamz smells a hidden/undocumented/unfinished routine for 4 parameters!

laugh
Posted By: RoCk Re: $istok behavior ? - 21/11/07 03:53 PM

* RoCk nods
Posted By: Wims Re: $istok behavior ? - 21/11/07 04:20 PM
Originally Posted By: RoCk
Odd as all of the results are, it seems to me that when used correctly, it seems to work correctly.
True, i found this with a typo smile

Originally Posted By: Mpdreamz
*Mpdreamz smells a hidden/undocumented/unfinished routine for 4 parameters!
Ha ha, maybe, but i don't see how $istok should works with 4 parameters, *see the post of jaytea*
Posted By: RoCk Re: $istok behavior ? - 21/11/07 04:37 PM

Originally Posted By: Mpdreamz

*Mpdreamz smells a hidden/undocumented/unfinished routine for 4 parameters!



I tried all of those on v5.5 with the same results, so it's been there since $istok was added.

//echo -a --> $version $istok(1,2,3,4)
--> 5.5 $false

//echo -a --> $version $istok(1,2,987361234,3)
--> 5.5 $false

//echo -a --> $version $istok(1,2,n,4)
--> 5.5 $true

//echo -a --> $version $istok(.,.,1a,.) - $istok(.,.,2a,.)
--> 5.5 $true - $false
Posted By: Wims Re: $istok behavior ? - 22/11/07 11:52 PM
Hum, not sure how considering this smirk
Actually i have :

Code:
elseif ($istok(96 64.112 64.96 80.112 80.128 80.128 64. $&
    .144 64.144 80.0 112.16 112.16 128.0 128.32 128.32 112. $&
    .48 112.48 128.64 128.64 112.80 112.80 128.96 128.96 112. $&
    .112 112.112 128.0 144.16 144.16 144.16 160.0 160.0 176. $&
    .16 176.16 192.0 192.32 192.32 176.48 176.48 192.32 160. $&
    .48 160.32 144.48 144.64 144.64 160.80 160.80 144.64 176. $&
    .80 176.64 192.80 192.,$1 $2,46)) return 32 32
This way, the code works as it should but first, i've tryed :
Code:
elseif ($istok(96 64.112 64.96 80.112 80.128 80.128 64. $&
    144 64.144 80.0 112.16 112.16 128.0 128.32 128.32 112. $&
    48 112.48 128.64 128.64 112.80 112.80 128.96 128.96 112. $&
    112 112.112 128.0 144.16 144.16 144.16 160.0 160.0 176. $&
    16 176.16 192.0 192.32 192.32 176.48 176.48 192.32 160. $&
    48 160.32 144.48 144.64 144.64 160.80 160.80 144.64 176. $&
    80 176.64 192.80 192.,$1 $2,46)) return 32 32
And i've seen that all match X Y on the left (144 64,48 112,112 112,etc...) are not detected whereas i'm sure about $1 and $2.So i've tryed :
Code:
elseif ($istok(96 64.112 64.96 80.112 80.128 80.128 64 $&
    .144 64.144 80.0 112.16 112.16 128.0 128.32 128.32 112 $&
    .48 112.48 128.64 128.64 112.80 112.80 128.96 128.96 112 $&
    .112 112.112 128.0 144.16 144.16 144.16 160.0 160.0 176 $&
    .16 176.16 192.0 192.32 192.32 176.48 176.48 192.32 160 $&
    .48 160.32 144.48 144.64 144.64 160.80 160.80 144.64 176 $&
    .80 176.64 192.80 192.,$1 $2,46)) return 32 32
And in this case, it's all the match on the right that are not detected.

Is this a bug or a someone have an explanation wink ?
Posted By: Wims Re: $istok behavior ? - 22/05/08 09:19 AM
The $istok behavior hasn't been fixed in mIRC 6.32 frown
And i'm still looking for an answer about the $& part, i think it's a bug because if i use a space as a token, it works fine, but with any other token, i have to use $+ $&.
Posted By: qwerty Re: $istok behavior ? - 22/05/08 10:10 AM
The $& thing is normal. When you use
Code:
$istok(96 64.112 64.96 80.112 80.128 80.128 64. $&
    144 64,$1 $2,46)
that translates to
Code:
$istok(96 64.112 64.96 80.112 80.128 80.128 64. 144 64,$1 $2,46)
Notice the space between . and 144: the period-separated token is now " 144 64", not "144 64", so it will never match "$1 $2". In this respect, $& is not like $+ but like all other identifiers: if there's a space before $&, it will be included in the "translated" single line.
Posted By: Wims Re: $istok behavior ? - 22/05/08 10:34 AM
That's why using $+ $& works, Thank you smile
Posted By: Khaled Re: $istok behavior ? - 25/05/08 10:59 AM
The reason for this is that $istok() is a special case of $findtok() and uses the same routine. I can make $istok() return an error on four or more parameters, however there are probably quite a few identifiers that don't return an error if you use too many parameters.
Posted By: Chessnut Re: $istok behavior ? - 25/05/08 12:17 PM
Currently, the behaviour with the third parameter seems to be that it specifies how many tokens have to be present in the text in order to return $true.

i.e.:

Code:
$istok(a.b.c.d.d.d.e,d,3,46) returns $true
$istok(a.b.c.d.d.d.e,d,4,46) returns $false because there are only 3 tokens of "d".


In my opinion, it's a useful addition to $istok, and instead of returning an error for four parameters, I think it would be nice to see the third parameter documented.
Posted By: Wims Re: $istok behavior ? - 25/05/08 03:51 PM
Hum, yes, could be useful
© mIRC Discussion Forums