mIRC Home    About    Download    Register    News    Help

Print Thread
Nested while loops issue #269642 23/11/21 11:54 PM
Joined: Jan 2004
Posts: 1,653
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,653
Possibly related to this post, it appears that nested while's on one line are preventing the /break command from working.

Code
//var %i 5 | while (%i) { var %t $ticks + 1000 | while (%t > $ticks) { noop } | echo -a $asctime i= %i | if (%i == 3) goto label | dec -s %i } | echo -a test1 | :label | echo -a test2


Code
//var %i 5 | while (%i) { var %t $ticks + 1000 | while (%t > $ticks) { noop } | echo -a $asctime i= %i | if (%i == 3) break | dec -s %i } | echo -a test1 | :label | echo -a test2


The 1st command correctly goto's to the label when %i reaches 3.

In old behavior, the 2nd of the above commands did a 'normal' loop exit at the bottom of the loop, immediately after decrementing %i to 4, instead of waiting until %i reached 3.

It should exit the loop immediately after displaying the message showing %i was now 3, but instead it now it repeats the outer while() repeatedly until %i reaches zero.

--

The above issue might be related to the issue of the {} required around the /noop for the inner while, as mentioned in https://forums.mirc.com/ubbthreads....e-loops-on-single-line-issues#Post264499

edit: seems /continue is being ignored same as /break is. The continue should prevent the /echo from being displayed at all:

//var %i 3 | while (%i) { dec -s %i | var %t $ticks + 1000 | while (%t > $ticks) { noop } | continue | echo -a this should not show }

Last edited by Khaled; 12/12/21 10:55 AM.
Re: Nested while loops issue [Re: maroon] #269694 13/12/21 09:08 AM
Joined: Dec 2002
Posts: 5,034
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,034
Thanks this has been fixed for the next version.