Solved - continue level not ignoring if blocks?

Things you’d like to miss in the future...
Post Reply
highend
Posts: 13311
Joined: 06 Feb 2011 00:33

Solved - continue level not ignoring if blocks?

Post by highend »

The help file states:
The argument ignores IF blocks.
Test code:

Code: Select all

    while ($i++ < 5) {
        if ($i == 2) {
            sysdebug "Condition i == 2";
            $j = 0;
            while ($j++ < 5) {
                if ($j == 2) { continue 2; }
                sysdebug "j: " . $j;
            }
        }
        sysdebug "i: " . $i;
    }
Debug output:

Code: Select all

i: 1
Condition i == 2
j: 1
i: 2
i: 3
i: 4
i: 5
On $j == 2 it should continue both loops and the i: 2 should never be reached

But that's not the case, it only works as expected with continue 3;
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 60542
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: continue level not ignoring if blocks?

Post by admin »

Indeed. Should work correctly in next beta.

highend
Posts: 13311
Joined: 06 Feb 2011 00:33

Re: Solved - continue level not ignoring if blocks?

Post by highend »

Fixed with 21.30.0048
Thanks!
One of my scripts helped you out? Please donate via Paypal

highend
Posts: 13311
Joined: 06 Feb 2011 00:33

Re: Solved - continue level not ignoring if blocks?

Post by highend »

continue was solved but break has the same problem... Can you please have a second look?
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 60542
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Solved - continue level not ignoring if blocks?

Post by admin »

Hm, the fix should be good for break as well. :? Do you have another example code?

highend
Posts: 13311
Joined: 06 Feb 2011 00:33

Re: Solved - continue level not ignoring if blocks?

Post by highend »

It seems this is more about what happens on break...

Code: Select all

    $items1 = "a|b|c";
    $items2 = "1|2|3";

    foreach($itemChar, $items1) {
        sysdebug "itemChar: " . $itemChar;

        if ($itemChar LikeI "a") {
            sysdebug "itemChar == a";

            foreach($itemNumber, $items2) {
                sysdebug "itemNumber: " . $itemNumber;

                if ($itemNumber == 1) {
                    sysdebug "itemNumber == 1";
                    break 1;
                }
            }
        } else {
            sysdebug "ELSE: itemChar: " . $itemChar;
        }
    }
Output:

Code: Select all

itemChar: a
itemChar == a
itemNumber: 1
itemNumber == 1
ELSE: itemChar: a
itemChar: b
ELSE: itemChar: b
itemChar: c
ELSE: itemChar: c
It breaks the inner foreach loop and then executes the else part of the outer one.
Afaik this wasn't the case in previous versions (judging from one of my main scripts that exists since years with a break level of 2 (3 foreach loops construction) and that I use 100 times a day which now only works with a break level of 3 because an else part is executed leading to a double clicked item to be processed twice (if break level is still 2)...
One of my scripts helped you out? Please donate via Paypal

highend
Posts: 13311
Joined: 06 Feb 2011 00:33

Re: Solved - continue level not ignoring if blocks?

Post by highend »

Yeah, just tried v21.30 to make sure my assumption is correct.

That one outputs this:

Code: Select all

itemChar: a
itemChar == a
itemNumber: 1
itemNumber == 1
itemChar: b
ELSE: itemChar: b
itemChar: c
ELSE: itemChar: c
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 60542
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Solved - continue level not ignoring if blocks?

Post by admin »

Right, both continue and break were still wrong. Next beta...

highend
Posts: 13311
Joined: 06 Feb 2011 00:33

Re: Solved - continue level not ignoring if blocks?

Post by highend »

Seems to be fixed now. Thanks!
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4139
Joined: 28 Feb 2012 19:27

Re: Solved - continue level not ignoring if blocks?

Post by klownboy »

highend wrote: 19 Dec 2020 16:48 Seems to be fixed now.
Not for old scripts using SC break. Still trying to figure out how to fix. In this case the break is on an else, which is within a while which is within 2 nested if's. Good grief Charlie Brown! The script was uploaded here viewtopic.php?f=7&t=21942 . Though that one is not my latest, it is broken too.

Code: Select all

	if !($newfilter) { // the filter is "0". Filter off ($idx is "1")
		filter "",6;}
	else {
		if (($filtertype == "Age") && ($trigger == "1") && ($mod != "2")) {
				while($idx > 1) {
					$files = quicksearch("ageM: <= $newfilter d /nf",,"|");
					if (gettoken($files, "count", "|") < 1) {
						$idx = ($idx == $stateCount ? 1 : $idx+1);
						$newState = GetToken($states, $idx, <crlf>);
						$origname .= $name . " or ";
						$name = GetToken($newState, 1, '|');
						$newfilter = GetToken($newState, 2, '|');
					}
					else {break;}
				}
		}
		elseif (($filtertype == "Age") && ($trigger == "2") && ($mod != "2")) {
				while($idx > 1) {
					$files = quicksearch("ageM: <= $newfilter d /nf",,"|");
					if (gettoken($files, "count", "|") < 1) {

						$idx = ($idx == $stateCount ? 1 : $idx+1);// go foward instead of back if $files="" on quicksearch.
						if($files == "") {
							$idx = "1";            //since the next age filter has no files reverse back to "Filter off"
						}
						$origname .= $name . " or ";
						$newState = GetToken($states, $idx, <crlf>);
						$name = GetToken($newState, 1, '|');
						$newfilter = GetToken($newState, 2, '|');
					}
					else {break;}
				}
		}
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

klownboy
Posts: 4139
Joined: 28 Feb 2012 19:27

Re: Solved - continue level not ignoring if blocks?

Post by klownboy »

This change is definitely breaking some old scripts. I can't be the only one affected. Maybe we should consider changing the help file to reflect the way it's been for years instead of changing the code to the help file. :eh:
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

admin
Site Admin
Posts: 60542
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Solved - continue level not ignoring if blocks?

Post by admin »

It's just a bit more tricky than I thought. Let's try the next beta...

klownboy
Posts: 4139
Joined: 28 Feb 2012 19:27

Re: Solved - continue level not ignoring if blocks?

Post by klownboy »

Thanks Don. I started to wonder if I had coded some scripts (possibly incorrectly) especially those years ago just to make them work and not necessarily knowing there may have been an issue or bug involved. Well, I suppose that could still be the case. :)
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

klownboy
Posts: 4139
Joined: 28 Feb 2012 19:27

Re: Solved - continue level not ignoring if blocks?

Post by klownboy »

Hi Don, it looks like v21.30.0050 fixed the issue I was having above with my age or size filtering script. I haven't checked all my scripts that have if, break, and continue, but hopefully all is well. Thanks very much. :tup:
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Post Reply