mIRC Home    About    Download    Register    News    Help

Print Thread
#212031 08/05/09 09:47 PM
Joined: Jul 2006
Posts: 4,155
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,155
I'm working on a code that give me this error, it's the first time I see it.
It's odd because sometime the code does work, sometime mirc is displaying this error, does someone knows what that mean ?


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Why don't you show the code that can reproduce this error?


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Jul 2006
Posts: 4,155
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,155
Because if someone knows what cause that, he does not need to see a code, but here is the line :
Code:
else while ($calc($1 $iif($r(0,1),-,+) $r( [ %rxecart ] )) & $calc($2 - $r( [ %ryecart ] ))) { var -s %x $v1 ,%y $v2 ,%x $iif($inrect(%x,%y,0,0,200,400),%x) ,%y $iif($inrect(%x,%y,0,0,200,400),%y) | if (%x != $null) break }

Look like the mirc parser does not like my unreadable code wink

Last edited by Wims; 08/05/09 10:14 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Looks like you basically answered your own question, then...


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
However I don't see much that can be made "unambiguous" in the condition:
Code:
else while ($calc($1 $iif($r(0,1),-,+) $r( [ %rxecart ] )) & $calc($2 - $r( [ %ryecart ] ))) { }
else while ($calc(A +/- B) & $calc(C - D)) { }
else while (X bitwise Y) { }


...besides of course (blind guess):
Code:
else {
  while (condition) { }
}


Edit: I suppose it's the "else while", for the following code will produce the error, and adding { } arround the else statement fixes it:
Code:
//var %x = 1 | if (!%x) noop | else while (%x < 3) { echo -sg %x | inc %x }


Joined: Jul 2006
Posts: 4,155
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,155
Yes and no.
Yes because adding extra bracket in the else like :
Code:
else {
while () { }
}
resolve the problem.
See horstl's post
But no because I would like to have a better explanation that what you gave me...
Actually,
Originally Posted By: /help /if
Using brackets speeds up processing. If an alias uses too few brackets then the statement might be ambiguous and the alias will take longer to parse, might be parsed incorrectly, or might not be parsed at all
is probably an answer but then another question have to be answered, how mirc can parse a line, said the line is valid a first time, and then displaying such an error for the exact same line ?
It's not the first odd behavior with /while so I imagine this is normal, I just find the behavior really weird

Last edited by Wims; 08/05/09 11:13 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
You're making it seem like the behaviour is random-- it is not.

The parser will consistently parse the while one time and then fail, which is what Horstl's simplified example shows.

There's a simple explanation for why it does it once, and there's an equally simple explanation for why it would fail the second time:

The first time around is parsed normally as if reading normally through a page in a book. Once the end of the while loop is found, the parser has to jump back, but in this case, when there is an ambiguity of where to jump, the parser cannot "find" the beginning of the loop and fails.

Why mIRC is not able to jump back even though it found the while loop the first time may have to do with the implementation details of how the parser keeps state during execution. The results, however, are not random.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Jul 2006
Posts: 4,155
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,155
That make sense thanks, the random part was in my code smile


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard