mIRC Home    About    Download    Register    News    Help

Print Thread
#176331 08/05/07 12:07 PM
B
bac0n
bac0n
B
Hi!

$gettok(a.b..d.f,3,46)

shouldnt this return $null ?

Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
By design, token identifiers ignore null tokens.

B
bac0n
bac0n
B
...and no re-design in sight?

Joined: Jan 2004
Posts: 2,081
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Jan 2004
Posts: 2,081
no redesign in sight, this is related to the issue of ignoring duplicate consecutive spaces. Any re-design here would break a high percentage of existing scripts.

Joined: Dec 2002
Posts: 1,999
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 1,999
Quote:
would break a high percentage of existing scripts.


I get so tired of reading that. Scripts are supposed to
conform with mIRC, not vice-versa. If a few scripts break
because of evolution in the mIRC scripting language, then
so be it, they can be fixed. Broken scripts shouldn't have
any weight whatsoever in any decisions to make changes
to the language.

Joined: Nov 2004
Posts: 822
Hoopy frood
Offline
Hoopy frood
Joined: Nov 2004
Posts: 822
You could always ask for some kind of .prop value that returns null values. That way the $gettok() identifier (And other $*tok*() identifiers.) are "fixed", and no scripts would be broken. smile

It'll also help me as well, since I plan on writing an IRCd with a "proper" config at some point.

Joined: Dec 2002
Posts: 580
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
I like the idea of a $prop to not ignore null tokens... smile

I also wrote a DLL awhile back that can do this...

Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
Nobody except Khaled can know for sure, but I too think it's not going to happen. A .prop is a much better (and plausible) idea.

In the meantime, if you're interested in a scripted solution, you may find this handy:
Code:
alias gettokn {
  var %c = \x $+ $base($3,10,16,2)
  returnex $remove($gettok($regsubex($1,/(?<=^| %c )(?=$| %c )/gx,$lf),$2,$3),$lf)
}
It works exactly the same way as $gettok() except it supports null tokens. The only catch is that it won't work correctly if the input string contains linefeed (ASCII 10) characters, quite unlikely with strings meant for IRC. Adding support for LF while preserving the original functionality would slow down the alias (because it would have to be more complex). It's not worth it imo, considering the rarity of the cases where LF is present in the input.

Joined: Nov 2004
Posts: 822
Hoopy frood
Offline
Hoopy frood
Joined: Nov 2004
Posts: 822
Wow, that's pretty neat. smile

B
bac0n
bac0n
B
var %a = 1

while ( a% <= $gettok(a.b..d.e.f.,0,46)) {
var %b = $gettok(a.b..d.e.f.,%a,46)
...
...
...
inc %a
}

I still think you gain alot more to use $null
and mirc are the only one having this behavior and current behavior are probably causing more problems than it solves.

best would be "array %list[10]" <--- this will save many lives :)=

Joined: Jan 2004
Posts: 2,081
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Jan 2004
Posts: 2,081
To avoid problems where null token causes script to se $gettok(a.b..d.e,4,46)is 'e' instead of 'd', you can use placeholder of a character that will never appear in the string. Such as checking to see if you are storing a NULL token and storing $chr(3) instead. Then, when retrieving tokens, you use $remove(token,$chr(3)). It doesn't matter what you use in place of $chr(3), as long as it's something that should never appear in the string.

Or: return $iif(token == $chr(3),$null,token)

R
RRX
RRX
R
Originally Posted By: maroon
no redesign in sight, this is related to the issue of ignoring duplicate consecutive spaces. Any re-design here would break a high percentage of existing scripts.

That is not very consequent with how /filter -t sorts, it fails to sort as intended, due to consecutive token separators.


Link Copied to Clipboard