mIRC Home    About    Download    Register    News    Help

Topic Options
#133106 - 17/10/05 10:53 AM /tokenize and $null
NaquadaServ Offline
Fjord artisan

Registered: 12/12/02
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
_________________________
NaquadaBomb
www.mirc-dll.com

Top
#133107 - 17/10/05 11:55 AM Re: /tokenize and $null
ClickHeRe Offline
Fjord artisan

Registered: 29/01/03
Posts: 249
Loc: Ottawa, Canada
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.
_________________________
David

DCX - Dialog Control eXtension

Top
#133108 - 17/10/05 04:40 PM Re: /tokenize and $null
NaquadaServ Offline
Fjord artisan

Registered: 12/12/02
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.
_________________________
NaquadaBomb
www.mirc-dll.com

Top
#133109 - 17/10/05 04:42 PM Re: /tokenize and $null
mIRCManiac Offline
Hoopy frood

Registered: 05/02/05
Posts: 681
Loc: Your dreams ;)
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 -


Edited by mIRCManiac (17/10/05 04:46 PM)
_________________________
mIRCManiac

Top
#133110 - 17/10/05 10:49 PM Re: /tokenize and $null
DaveC Offline
Planetary brain

Registered: 26/09/03
Posts: 4230
Quote:
//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 -

Top
#133111 - 17/10/05 11:29 PM Re: /tokenize and $null
starbucks_mafia Offline
Hoopy frood

Registered: 09/12/02
Posts: 2962
Loc: Norwich, UK
Quote:
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:
Code:
/msg   someguy hi there!

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.

Top
#133112 - 17/10/05 11:41 PM Re: /tokenize and $null
mIRCManiac Offline
Hoopy frood

Registered: 05/02/05
Posts: 681
Loc: Your dreams ;)
[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.

Quote:

//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 <-- 1
1 - 2 - 3 == 1 - 3 - <-- 2

Actual results
Expected results


Edited by mIRCManiac (18/10/05 12:13 AM)
_________________________
mIRCManiac

Top
#133113 - 18/10/05 12:21 AM Re: /tokenize and $null
DaveC Offline
Planetary brain

Registered: 26/09/03
Posts: 4230
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 $+()
Code:
//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.
Code:
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

Top
#133114 - 19/10/05 06:34 PM Re: /tokenize and $null
NaquadaServ Offline
Fjord artisan

Registered: 12/12/02
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 -
_________________________
NaquadaBomb
www.mirc-dll.com

Top
#133115 - 19/10/05 06:50 PM Re: /tokenize and $null
NaquadaServ Offline
Fjord artisan

Registered: 12/12/02
Posts: 580
Quote:
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.

Code:
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
}

Top
#133116 - 19/10/05 07:53 PM Re: /tokenize and $null
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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. smile

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

Top
#133117 - 19/10/05 08:52 PM Re: /tokenize and $null
DaveC Offline
Planetary brain

Registered: 26/09/03
Posts: 4230
Quote:
Are you serious? I would love to see an example of where this might be useful...

Code:
alias committurn {
  var %players = $gamevalue($1,$2,$3,&lt;,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,&lt;,$gettok(%order,1,32)) $gamevalue($1,$2,$3,&lt;,$gettok(%order,2,32))  $gamevalue($1,$2,$3,&lt;,$gettok(%order,3,32))  $gamevalue($1,$2,$3,&lt;,$gettok(%order,4,32))  $gamevalue($1,$2,$3,&lt;,$gettok(%order,5,32))  $gamevalue($1,$2,$3,&lt;,$gettok(%order,6,32))  $gamevalue($1,$2,$3,&lt;,$gettok(%order,7,32))  $gamevalue($1,$2,$3,&lt;,$gettok(%order,8,32))
  commitactions $1-
}



Quote:
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.

Top