mIRC Home    About    Download    Register    News    Help

Print Thread
#235625 31/12/11 04:02 AM
Joined: Jun 2007
Posts: 35
Ameglian cow
OP Offline
Ameglian cow
Joined: Jun 2007
Posts: 35
Hi,

Code:
alias test {
  var %row = 0
  while (%row < 5) {
    var %col = 0
    while (%col < 5) {
      if (0 == 0) {
        inc %col
        while ((%col < 5) && $&
          (0 == 0)) {
          inc %col
        }
      }
      inc %col
    }
    inc %row
  }
}

I get the following error when the innermost loop finishes its first step:

* /while: loop not found (line 9, remote.ini)

Removing the $& line break makes the problem go away.

mIRC version: 7.22

Thanks smile


Desired: right alignment of text; consecutive spaces in /command args; Ctrl+A in custom dialogs.
Joined: Jun 2007
Posts: 35
Ameglian cow
OP Offline
Ameglian cow
Joined: Jun 2007
Posts: 35
Actually...

Code:
alias test {
  var %i = 0
  while ((%i < 10) && $&
    (0 == 0)) {
     inc %i
  }
}


Desired: right alignment of text; consecutive spaces in /command args; Ctrl+A in custom dialogs.
Joined: Oct 2010
Posts: 28
D
Ameglian cow
Offline
Ameglian cow
D
Joined: Oct 2010
Posts: 28
why are you trying to use $& in a loop anyway?

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
The same reason you would use $& anywhere else. It seems legitimate to want to use $& in a while/if condition. Note that $& works in if conditions:

Code:
alias testif {
  if ((0 == 0) && $&
    (1 == 1)) {
    echo -a this works in 7.22
  }
}


So it should be equally valid in while conditions.

I should point out that even though the while loop fails to "loop", the condition part does actually work. In other words:

Code:
alias test {
  var %i = 0
  while ((%i < 10) && $&
    (0 == 0)) {
     echo -a This works
     inc %i
  }
}


Does echo "This works" once before the error is displayed. It just fails to jump back to the beginning of the loop and iterate multiple times. I imagine the bug is that mIRC thinks the continuation line for the loop is on line 4 of that alias because that's where it ends, so it jumps back there and doesn't find the /while command. mIRC should register the "continuation line" as the beginning of the while line, not the end.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Jun 2007
Posts: 35
Ameglian cow
OP Offline
Ameglian cow
Joined: Jun 2007
Posts: 35
What argv0 said.

$& is for improving code readability. If code lines are too long, you may be forced to scroll horizontally, which is undesirable. What I showed here was just demo code, but originally the loop condition line was very long. (I probably should've written it more elegantly, but that's a different story. smile )

Actually, I'm seriously surprised no one's ever bumped into such a general use case (myself included).


Desired: right alignment of text; consecutive spaces in /command args; Ctrl+A in custom dialogs.
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Originally Posted By: alephresh
Actually, I'm seriously surprised no one's ever bumped into such a general use case (myself included).


My guess is most people aren't aware of $&. That, coupled with the fact that there tend to be better ways to split statements up into multiple lines, and the fact that most scripters don't seem to care how long their lines are (see some pastes in the Scripting section of this forum for examples of rampant long line abuse), lead to a pretty low chance of this having been used in a while loop by someone who actually spends the time to report bugs. I should point out, the people who spend time to report bugs are already in the minority smile


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Jun 2007
Posts: 35
Ameglian cow
OP Offline
Ameglian cow
Joined: Jun 2007
Posts: 35
Thought I might bump this.


Desired: right alignment of text; consecutive spaces in /command args; Ctrl+A in custom dialogs.
Joined: Dec 2002
Posts: 5,408
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,408
Thanks this issue has been fixed for the next version.

Joined: Jun 2007
Posts: 35
Ameglian cow
OP Offline
Ameglian cow
Joined: Jun 2007
Posts: 35
Originally Posted By: Khaled
Thanks this issue has been fixed for the next version.

Thanks! There's no error now, but there's a logical issue - this only echoes "1":

Code:
alias test {
  var %i = 0
  while ((%i < 10) && $&
    (0 == 0)) {
     inc %i
     echo -ag %i
  }
}

(It only took me 6 years to check the fix... smile )


Desired: right alignment of text; consecutive spaces in /command args; Ctrl+A in custom dialogs.
Joined: Dec 2002
Posts: 5,408
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,408
Thanks for your bug report. This is a tricky fix as $& parsing takes place in a specific point in the parser, so it has had to be integrated into while loop parsing, which is much more complicated. I have implemented a fix for the next beta but it will need testing.


Link Copied to Clipboard