mIRC Home    About    Download    Register    News    Help

Print Thread
#215051 29/08/09 11:39 PM
Joined: Jul 2006
Posts: 4,145
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
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
Wims #215054 30/08/09 04:21 PM
Joined: Jul 2006
Posts: 4,145
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
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
Wims #215089 02/09/09 03:02 PM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Code:

//if ($?="try it") echo -a ok | else echo -a ok1



Works fine here.

Joined: Jul 2006
Posts: 4,145
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
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
Wims #215105 02/09/09 07:38 PM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
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"
argv0 #215109 02/09/09 08:21 PM
Joined: Jul 2006
Posts: 4,145
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Quote:
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.
Quote:
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
Wims #215115 03/09/09 04:28 AM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Although not technically a silent "halting":

Code:
//if (0) { shh } else { echo -a hi }


Of course there's also:

Code:
if (1 == 1) { echo -a hi } }
echo -a hi


Again, not quite "halting":

Code:
; 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"
Wims #215116 03/09/09 05:03 AM
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
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.


Link Copied to Clipboard