|
|
Joined: Jul 2006
Posts: 4,145
Hoopy frood
|
OP
Hoopy frood
Joined: Jul 2006
Posts: 4,145 |
If I miss the first " with $? :
//if ($?try it") echo -a ok | else echo -a ok1
mirc see it as $?, and then display "* /if: invalid format". If I miss the second " :
//if ($?"try it) echo -a ok | else echo -a ok1
mirc just take it as a /halt command
I think that both exemple should return an error about $? syntax
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Jul 2006
Posts: 4,145
Hoopy frood
|
OP
Hoopy frood
Joined: Jul 2006
Posts: 4,145 |
I have missed the '=' in my test (syntax is $?="text"), but it does not change anything.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Oct 2005
Posts: 1,741
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,741 |
//if ($?="try it") echo -a ok | else echo -a ok1
Works fine here.
|
|
|
|
Joined: Jul 2006
Posts: 4,145
Hoopy frood
|
OP
Hoopy frood
Joined: Jul 2006
Posts: 4,145 |
Of course, you're using the right syntax, I'm saying mirc should report an syntax error when I use $? incorrectly
Last edited by Wims; 02/09/09 07:14 PM.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Oct 2003
Posts: 3,918
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,918 |
$?try is valid $?=try is valid
The problem only occurs when there is an unbalanced number of "'s in the call.
mIRC will either take the first full word succeeding the "$?", ignoring an = if it is the first character. Consider the following:
//echo -a $?try //echo -a $?=try //echo -a $?==
Here's the important part: if it encounters a " it will ignore all the previous characters and start fresh until it finds the ending "
//echo -a $?try" harder" ; shows "harder" as the message
It looks until the end of the line (or next `|`) for the ending ". If it doesn't find it it silently errors out. It could show an error message for this instead, but it's certainly not a "bug". The behaviour is quite undefined and there are hundreds of places where syntax errors cause silent halting of scripts, in mIRC.
For completeness, this explains why your example works in the first case and not the second. ($?try it") is just "RESULTS OF $?try followed by `it"`, `it"` being an invalid operator.
The second one is that missing " case we were just talking about, which is why its problematic. If you had tryit without a space, both cases would fail.
- argv[0] on EFnet #mIRC - "Life is a pointer to an integer without a cast"
|
|
|
|
Joined: Jul 2006
Posts: 4,145
Hoopy frood
|
OP
Hoopy frood
Joined: Jul 2006
Posts: 4,145 |
It could show an error message for this instead, but it's certainly not a "bug".The behaviour is quite undefined and there are hundreds of places where syntax errors cause silent halting of scripts, in mIRC. Yeah, an error message in such case is what I'm talking about. there are hundreds of places where syntax errors cause silent halting of scripts Like ?
Last edited by Wims; 02/09/09 08:22 PM.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Oct 2003
Posts: 3,918
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,918 |
Although not technically a silent "halting": //if (0) { shh } else { echo -a hi } Of course there's also: if (1 == 1) { echo -a hi } }
echo -a hi Again, not quite "halting":
; this works without the space
menu nicklist, channel {
MENUITEM:echo -a hi
}
I should modify "halting" to mean "breaking". There are plenty of other examples where mIRC could/should/would give some kind of error but doesn't.
- argv[0] on EFnet #mIRC - "Life is a pointer to an integer without a cast"
|
|
|
|
Joined: Jan 2007
Posts: 1,156
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
I think the error message is sufficient considering the many different types of errors it encompasses. When it gives me that error with a line number its pretty easy to figure out what is wrong.
|
|
|
|
|
|