|
Joined: Dec 2002
Posts: 580
Fjord artisan
|
OP
Fjord artisan
Joined: Dec 2002
Posts: 580 |
This really should be called a bug, but I think some may disagree that's it's a bug. It certainly sucks to work-around.
//tokenize 44 1,2,3 | echo -a $1 - $2 - $3 == 1 - 2 - 3 //tokenize 44 1,2,3 | echo -a $1 - $2 - $3 == 1 - 3 -
Do I really need to explain why it isn't good that /tokenize act this way? If I write a script that expects $3 to be "3", it's now $null. The reason /tokenize does this is probably linked with X>1 spaces is always one space (why do that?!?!?!).
Also but related, token handling identifers (such as $gettok), should support $null tokens for the same reason.
Naquada
|
|
|
|
Joined: Jan 2003
Posts: 249
Fjord artisan
|
Fjord artisan
Joined: Jan 2003
Posts: 249 |
I think the spaces you meant are not there, you should enclose your example into code tags to preserve the space aspect of it.
And mIRC has always done this before in removing spaces and I don't think it will change in the futur. Same thing with null tokens in the $*tok idents.
|
|
|
|
Joined: Dec 2002
Posts: 580
Fjord artisan
|
OP
Fjord artisan
Joined: Dec 2002
Posts: 580 |
Not talking about spaces (well not specifically), I'm only talking about $null tokens.
Yeah always done it, but that's not to say it's wise to keep it.
|
|
|
|
Joined: Feb 2005
Posts: 681
Fjord artisan
|
Fjord artisan
Joined: Feb 2005
Posts: 681 |
I think he means your two examples above are identical except for the missing 2 and shifted 3.
Yours //tokenize 44 1,2,3 | echo -a $1 - $2 - $3 == 1 - 2 - 3 //tokenize 44 1,2,3 | echo -a $1 - $2 - $3 == 1 - 3 -
Did you mean it to be?.. //tokenize 44 1,2,3 | echo -a $1 - $2 - $3 == 1 - 2 - 3 //tokenize 44 1,,3 | echo -a $1 - $2 - $3 == 1 - 3 - 1 - 3 - == 1 - 3 -
or?.. //tokenize 44 1,2,3 | echo -a $1 - $2 - $3 == 1 - 2 - 3 //tokenize 44 1, ,3 | echo -a $1 - $2 - $3 == 1 - 3 - 1 - - 3 == 1 - 3 -
Last edited by mIRCManiac; 17/10/05 03:46 PM.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
//tokenize 44 1,2,3 | echo -a $1 - $2 - $3 == 1 - 2 - 3 //tokenize 44 1,2,3 | echo -a $1 - $2 - $3 == 1 - 3 - What are you on about?????? The results of above are.... 1 - 2 - 3 == 1 - 2 - 3 1 - 2 - 3 == 1 - 3 -
|
|
|
|
Joined: Dec 2002
Posts: 2,962
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,962 |
The reason /tokenize does this is probably linked with X>1 spaces is always one space (why do that?!?!?!). - Because when someone types something into the command-line like: the're about a one in a billion chance that they meant to try and send a message to someone with no nick. The same goes for pretty much every other IRC command. Remember that that's what mIRC scripting really was made for - to allow people to simplify/automate certain tasks within IRC, and so the 'language' is designed to aid people to that end. It was never originally intended to be someone's programming language of choice for any and every task, so why would things like null tokens have been supported? Changing the default behaviour now would be incredibly stupid.
Spelling mistakes, grammatical errors, and stupid comments are intentional.
|
|
|
|
Joined: Feb 2005
Posts: 681
Fjord artisan
|
Fjord artisan
Joined: Feb 2005
Posts: 681 |
[Rudeness removed by author], but the two tokenize commands in his examples are identical. I (and obviously ClickHeRe) think he intended for a couple of spaces, or a null token to be in his examples that are not. All he did was remove the 2 and shift the 3 in the expected result of his second example. //tokenize 44 1,2,3 | echo -a $1 - $2 - $3 == 1 - 2 - 3 <-- 1 //tokenize 44 1,2,3 | echo -a $1 - $2 - $3 == 1 - 3 - <-- 2
1 - 2 - 3 == 1 - 2 - 3 <-- 11 - 2 - 3 == 1 - 3 - <-- 2Actual results Expected results
Last edited by mIRCManiac; 17/10/05 11:13 PM.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
I dont think so, he mentiones not talking about spaces, looking at it again i now think he screwed up the example, i think he ment to use this //tokenize 44 1,2,3 | echo -a $1 - $2 - $3 == 1 - 2 - 3 //tokenize 44 1,,3 | echo -a $1 - $2 - $3 == 1 - 3 - I think hes saying the $null field between the 2 ,, should be seen as $2, and i can see where hes coming from with that ( not that i aggree). I used 46 over 44 becuase there easier to insert into a $+() //var %a = 1, %b = 1, %c = 3 | tokenize 46 $+(%a,.,%b,.,%c) | echo $!1= $1 $!2= $2 $!3= $3
$1= 1 $2= 2 $3= 3
.
//var %a = 1, %b = $null, %c = 3 | tokenize 46 $+(%a,.,%b,.,%c) | echo $!1= $1 $!2= $2 $!3= $3
$1= 1 $2= 3 $3= He wants to maintain the location of his values but insert them into $N values, with the posablility that any $N value maybe a $null string. As im sure you know you can call an alias as an identifier and manage the effect of creating $null $N values. alias example ( echo $!1= $1 $!2= $2 $!3= $3 )
//var %a = 1, %b = $null, %c = 3 | .echo -q $example(%a,%b,%c)
$1= 1 $2= $3= 3 I personally wouldnt like it, i have depended on the exact opersite effect , tokenize 32 %a %b %c, to get $1=1 and $2=3
|
|
|
|
Joined: Dec 2002
Posts: 580
Fjord artisan
|
OP
Fjord artisan
Joined: Dec 2002
Posts: 580 |
oops thanks...
I did mean...
//tokenize 44 1,2,3 | echo -a $1 - $2 - $3 == 1 - 2 - 3 //tokenize 44 1,,3 | echo -a $1 - $2 - $3 == 1 - 3 -
|
|
|
|
Joined: Dec 2002
Posts: 580
Fjord artisan
|
OP
Fjord artisan
Joined: Dec 2002
Posts: 580 |
I personally wouldnt like it, i have depended on the exact opersite effect , tokenize 32 %a %b %c, to get $1=1 and $2=3 Are you serious? I would love to see an example of where this might be useful... Here is my logic and reason... There is no easy way to pass null parameters to a signal... In effect this is what I'm trying to do.
alias usetest { echo -a $test(1, $null, 3) }
alias test { signal Blah $1 $2 $3 }
on *:signal:Blah:{
var %A $1 | var %B $2 | var %C $3
if (%B != $null) { return } ; Oops if $2 in 'test' was null, %B==3
; if $1 || $2 || $3 could == $null, How can I know which was $null
; since their location is meaningless
}
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
It may be a workaround, but you can always pass a special character for $null (this if for if you aren't using an alias, though it could be set up for use with the alias as well)... Pick a character (such as ~): if (%A == $null) var %A = ~ Or, use the word NULL: if (%A == $null) var %A = NULL Then, you can just ignore that character (or word) when looking at the data... it's basically just a spacer. Another option would be to put leading and/or trailing characters on all variables (this is for either with or without the alias)... var %A = .1. Then, when you get a $null, you have .. with nothing else (easy to notice). And the leading/trailing .'s are easy to remove when getting the data. You could, of course, choose another character instead of .'s. It was just an example. I think that changing $null would be very difficult as I believe all commands will ignore $null as if it's not there. To change it for this would mean it would need to be changed everywhere.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
Are you serious? I would love to see an example of where this might be useful... alias committurn {
var %players = $gamevalue($1,$2,$3,<,players), %text = $gettok(player1action player2action player3action player4action player5action player6action player7action player8action,$+(1-,%players),32), %order . . . . . . . .
while (%players) {
var %r = $r(1,%players), %order = $puttok(%order,$gettok(%text,%r,32),%players,32), %text = $deltok(%text,%r,32)
dec %players
}
tokenize 32 $1 $2 $3 $gamevalue($1,$2,$3,<,$gettok(%order,1,32)) $gamevalue($1,$2,$3,<,$gettok(%order,2,32)) $gamevalue($1,$2,$3,<,$gettok(%order,3,32)) $gamevalue($1,$2,$3,<,$gettok(%order,4,32)) $gamevalue($1,$2,$3,<,$gettok(%order,5,32)) $gamevalue($1,$2,$3,<,$gettok(%order,6,32)) $gamevalue($1,$2,$3,<,$gettok(%order,7,32)) $gamevalue($1,$2,$3,<,$gettok(%order,8,32))
commitactions $1-
} Here is my logic and reason... There is no easy way to pass null parameters to a signal... alias usetest { echo -a $test(1, $!null, 3) } or alias test { signal Blah $iif($1 == $null,$!null,$1) $iif($2 == $null,$!null,$2) $iif($3 == $null,$!null,$3) } Essentially what Ramius said, use a symbolic place holder, since "$null" is not quite but damn close to $null, functions the same when compared at least.
|
|
|
|
|