mIRC Home    About    Download    Register    News    Help

Topic Options
#109774 - 01/02/05 08:51 AM /tokenize doesn't give an error
Hrung Offline
Fjord artisan

Registered: 30/12/02
Posts: 208
I don't know that this would count as a bug as such, but I can't seem to get /tokenize to give an error message... Even using /tokenize with no parameters at all just skips on to the next command. Examples:

tokenize
tokenize a b c
tokenize 32

None of the above commands give any kind of error. I can see the "tokenize 32" not erroring, in case the user is tokenizing from a $null %var, but the other two should give insufficient/invalid parameters. Can make it kind of difficult to debug if you don't notice something small like that.
_________________________
If I knew now what I will know then... maybe things will have been different...

Top
#109775 - 01/02/05 07:55 PM Re: /tokenize doesn't give an error
starbucks_mafia Offline
Hoopy frood

Registered: 09/12/02
Posts: 2962
Loc: Norwich, UK
Well it doesn't error because it does perform an action: it makes $1- equal $null. I don't see how it really confuses anyone, I mean what would they expect to be happening with /tokenize without parameters assuming they understood the command's purpose.
_________________________
Spelling mistakes, grammatical errors, and stupid comments are intentional.

Top
#109776 - 01/02/05 08:30 PM Re: /tokenize doesn't give an error
Hrung Offline
Fjord artisan

Registered: 30/12/02
Posts: 208
The point is that it is easy to forget something simple, such as the C parameter to /tokenize, and without any kind of error message telling you that you messed it up, you could end up just sitting there scratching your head and wondering why $1- keeps coming out $null. The C parameter should be required for mirc to continue with that command. I don't know about anyone else, but when I'm debugging code, I find that error messages make it easier to locate errors -- that's kind of what they're there for. But for a command to produce no error when it is obviously being used incorrectly (C is not optional as far as getting it to actually work is concerned) is just plain wrong, hence the bug report.

The person that brought this bug to my attention forgot the C parameter, which is a simple mistake that anyone can make. Also, if a user is passing a %variable or $identifier (maybe a misspelling of $asc(C)?) it might take a while to figure out what went wrong where a simple "* /tokenize: invalid parameters" would tell them right off where they should be looking.


Edited by Hrung (01/02/05 08:38 PM)
_________________________
If I knew now what I will know then... maybe things will have been different...

Top
#109777 - 01/02/05 08:41 PM Re: /tokenize doesn't give an error
FiberOPtics Offline
Hoopy frood

Registered: 05/02/04
Posts: 2019
Loc: Leuven, Belgium
I second that.
_________________________
Gone.

Top
#109778 - 01/02/05 09:21 PM Re: /tokenize doesn't give an error
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
I see your second and i raise you a third
_________________________
- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Top
#109779 - 01/02/05 10:03 PM Re: /tokenize doesn't give an error
DaveC Offline
Planetary brain

Registered: 26/09/03
Posts: 4230
Quote:
Well it doesn't error because it does perform an action: it makes $1- equal $null. I don't see how it really confuses anyone, I mean what would they expect to be happening with /tokenize without parameters assuming they understood the command's purpose.


Yes yes yes, i totally agree and on those grounds I propose that all commands do not error, and the code continues to run (runaway i thinks might be a better word) regardless of what commands have failed, let it be on the coders head to find even the smallest of bugs in 1000's of lines of code i say!

Top
#109780 - 01/02/05 11:25 PM Re: /tokenize doesn't give an error
starbucks_mafia Offline
Hoopy frood

Registered: 09/12/02
Posts: 2962
Loc: Norwich, UK
Yes, the case of /tokenize <non-numeric> ... should be an error, but /tokenize alone should not because it is a valid command which performs a potentially useful function. Yes, that function could also be performed by /tokenize <any-number> $null, but the fact is that it works both ways so why change it? It's not like someone can easily forget both parameters for /tokenize is it?
_________________________
Spelling mistakes, grammatical errors, and stupid comments are intentional.

Top
#109781 - 01/02/05 11:28 PM Re: /tokenize doesn't give an error
starbucks_mafia Offline
Hoopy frood

Registered: 09/12/02
Posts: 2962
Loc: Norwich, UK
My point was/is that the command doesn't fail if /tokenize is used without parameters. Missing both parameters for a command isn't 'the smallest of bugs' or even a small bug, it's a glaring oversight.
_________________________
Spelling mistakes, grammatical errors, and stupid comments are intentional.

Top
#109782 - 02/02/05 06:04 AM Re: /tokenize doesn't give an error
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
That's wrong, any possible oversight is a wrong oversight. A script should not continue processing if errant code is run. Thats the point of the error messages- otherwise there are plenty of commands in mIRC that halt processing when theres no 'serious' error.

Let me illustrate the 'theres no such thing as a glaring error' syndrome:

1. Lost in code...where's waldo?

alias x { var %i, %x, %y, %n = $len($$1) | while (%i < %m) { inc %i | %x = $calc(5 + ($sqrt($$1 + $$3 / $floor($$1 + 2 / (18 + 555 * $$2))) | tokenize | %y = $base($abs($calc(%x + 5 + ($sqrt($$1 + $$3))), 10, 2, $left($$1,-1)) } | return %y }


You can blame the terrible coding style all you want, but the point is mIRC should tell the scripter what went wrong, or he might never find that needle in the haystack

or even...

2. Ignorance to the ways of mIRC
Code:
ON *:TEXT:!help:# { 
  msg $nick HELP INFO | tokenize | parameters: &lt;delim&gt; &lt;text&gt;
  msg $nick Description: tokenizes text based on a delimiter
}

A scripter might not be aware of the | used as a command delimiter. Sure, its his fault, but that should not justify mIRC not telling the scripter how to fix his error.


By the way, don't try to argue these examples- They're just examples. In fact, these examples should be considered simple cases of what can be a much more complex situation (a one line alias thats triple the size, a longer on text event, etc) The point stands.
_________________________
- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Top
#109783 - 02/02/05 01:23 PM Re: /tokenize doesn't give an error
JoeDaddy Offline
Vogon poet

Registered: 17/10/03
Posts: 96
You just nullified 3 variables at the beginning of that alias.
Many times I have done the same with /tokenize .. I don't
think it's a bug at all, if so, then the way you just used
/var is a bug as well .. it does the same thing with
no error.

Edit: But then again, if this is changed it woulnd't bother
me at all if I had to start using /tokenize [C] to get the
same effect.


Edited by JoeDaddy (02/02/05 03:05 PM)
_________________________
Somebody Rate Me 5 Stars PLEASE!!!
t}{3n | c0u|d b3 |33t t00!
gringringringrin

Top
#109784 - 02/02/05 03:12 PM Re: /tokenize doesn't give an error
qwerty Offline
Hoopy frood

Registered: 07/01/03
Posts: 2523
5.91 versions.txt:
Quote:
33./tokenize now correctly resets all $N to $null if no parameters
are specified.

It is intentional and I agree: /tokenize without params is a quick way to empty all $N's. I don't care whether /tokenize <invalid params> should give an error or not but /tokenize alone should not.
_________________________
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Top
#109785 - 02/02/05 03:16 PM Re: /tokenize doesn't give an error
JoeDaddy Offline
Vogon poet

Registered: 17/10/03
Posts: 96
heh good one .. I didn't remember that .. I still
don't, but at least that proves it was intentional
and behaves exactly as it should smile


Edited by JoeDaddy (02/02/05 03:28 PM)
_________________________
Somebody Rate Me 5 Stars PLEASE!!!
t}{3n | c0u|d b3 |33t t00!
gringringringrin

Top
#109786 - 02/02/05 05:38 PM Re: /tokenize doesn't give an error
Hrung Offline
Fjord artisan

Registered: 30/12/02
Posts: 208
So it behaves the way it was designed in that respect, but I can't think of a reason why someone would want to reset $1- to $null.. If you want $null, why not just use $null? Is there any possible advantage to it? If anyone has an idea, I really would like to know...
_________________________
If I knew now what I will know then... maybe things will have been different...

Top
#109787 - 02/02/05 05:48 PM Re: /tokenize doesn't give an error
tidy_trax Offline
Hoopy frood

Registered: 02/11/03
Posts: 2327
Some people use that feature in loops, for example:

Code:
alias test {
  tokenize 32 1 2 3
  while ($0) { 
    echo -a $1-
    ;The following line will give an error if this feature is removed from mIRC.
    tokenize 32 $2-
  }
}
_________________________
New username: hixxy

Top
#109788 - 02/02/05 06:20 PM Re: /tokenize doesn't give an error
Hrung Offline
Fjord artisan

Registered: 30/12/02
Posts: 208
That is an interesting example, and I can see doing that, but it still uses the C parameter to /tokenize. I'm talking about using /tokenize with no parameters. The only thing it could do is clear out $1-, which seems pretty much useless to me.
_________________________
If I knew now what I will know then... maybe things will have been different...

Top
#109789 - 02/02/05 08:02 PM Re: /tokenize doesn't give an error
starbucks_mafia Offline
Hoopy frood

Registered: 09/12/02
Posts: 2962
Loc: Norwich, UK
But, as I keep trying to explain, using /tokenize with no parameters is not errant code, it's a valid use of the command. My point about it not being a small error is that it's not something that you can do without thinking. You might get the parameters mixed up or even forget one, but you can't forget both parameters for the command.

If it's ignorance of the ways of mIRC, well that's hardly within mIRC's capability to second guess everything the scripter does.

eg.
Code:
ON *:TEXT:!help:# { 
  msg $nick HELP INFO | tokenize | parameters: &lt;delim&gt; &lt;text&gt;
  msg $nick Description: tokenizes text based on a delimiter
}

* Error: You may or may not have meant to create an event hook. 'on ...' creates an event hook in mIRC script.
* Error: You may or may not have meant to trigger the command 'msg $nick HELP INFO'. Newlines delimit commands in mIRC script.
* Error: You may or may not have meant to trigger the command 'tokenize'. Pipes delimit commands in mIRC script
* Error: You may or may not have meant to trigger the command 'parameters: <delim> <text>'. Pipes delimit commands in mIRC script
* Error: You may or may not have meant to trigger the command 'msg $nick Description: tokenizes text based on a delimiter'. Newlines delimit commands in mIRC script
* Error: You may or may not have meant to end the 'on TEXT' command block. Braces surround command blocks in mIRC script.


My point is hopefully obvious. At some point an error is going to be undetectable from genuine code. Error messages provide a way of finding, well, errors. They're not there to perform an on-the-fly scripting tutorial or give a running commentary on the state of the script. /tokenize without any parameters is a valid command, and as qwerty showed it is intentional.
_________________________
Spelling mistakes, grammatical errors, and stupid comments are intentional.

Top
#109790 - 02/02/05 08:10 PM Re: /tokenize doesn't give an error
JoeDaddy Offline
Vogon poet

Registered: 17/10/03
Posts: 96
lol .. hey look, it's ms word
_________________________
Somebody Rate Me 5 Stars PLEASE!!!
t}{3n | c0u|d b3 |33t t00!
gringringringrin

Top
#109791 - 02/02/05 10:18 PM Re: /tokenize doesn't give an error
milosh Offline
Fjord artisan

Registered: 24/12/03
Posts: 261
Loc: Srbija
I just want to say that every command should return error if it can not execute. Example /unload command... /unload -rs c:\program files\blabla doesn't give any kind of error message... and I just forgot to put " before and after the filename...

Top
#109792 - 02/02/05 10:38 PM Re: /tokenize doesn't give an error
JoeDaddy Offline
Vogon poet

Registered: 17/10/03
Posts: 96
Quote:
every command should return error if it can not execute

/tokenize by itself does execute and is intended
behavior .. proven by qwerty above from versions.txt.

Edit: I just became a member .. huhuh I said mmmember


Edited by JoeDaddy (02/02/05 10:40 PM)
_________________________
Somebody Rate Me 5 Stars PLEASE!!!
t}{3n | c0u|d b3 |33t t00!
gringringringrin

Top
#109793 - 02/02/05 11:00 PM Re: /tokenize doesn't give an error
milosh Offline
Fjord artisan

Registered: 24/12/03
Posts: 261
Loc: Srbija
Read my post carefully
Quote:
every command should return error if it can not execute

And I gave an example of command that does not do that...
_________________________
velicha dusha moja Gospoda

Top