Page 1 of 1

Solved - continue level not ignoring if blocks?

Posted: 11 Dec 2020 23:43
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;

Re: continue level not ignoring if blocks?

Posted: 18 Dec 2020 16:15
by admin
Indeed. Should work correctly in next beta.

Re: Solved - continue level not ignoring if blocks?

Posted: 18 Dec 2020 19:14
by highend
Fixed with 21.30.0048
Thanks!

Re: Solved - continue level not ignoring if blocks?

Posted: 18 Dec 2020 21:32
by highend
continue was solved but break has the same problem... Can you please have a second look?

Re: Solved - continue level not ignoring if blocks?

Posted: 19 Dec 2020 10:56
by admin
Hm, the fix should be good for break as well. :? Do you have another example code?

Re: Solved - continue level not ignoring if blocks?

Posted: 19 Dec 2020 11:32
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)...

Re: Solved - continue level not ignoring if blocks?

Posted: 19 Dec 2020 11:50
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

Re: Solved - continue level not ignoring if blocks?

Posted: 19 Dec 2020 15:54
by admin
Right, both continue and break were still wrong. Next beta...

Re: Solved - continue level not ignoring if blocks?

Posted: 19 Dec 2020 16:48
by highend
Seems to be fixed now. Thanks!

Re: Solved - continue level not ignoring if blocks?

Posted: 19 Dec 2020 17:13
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;}
				}
		}

Re: Solved - continue level not ignoring if blocks?

Posted: 19 Dec 2020 19:46
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:

Re: Solved - continue level not ignoring if blocks?

Posted: 20 Dec 2020 12:35
by admin
It's just a bit more tricky than I thought. Let's try the next beta...

Re: Solved - continue level not ignoring if blocks?

Posted: 20 Dec 2020 14:52
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. :)

Re: Solved - continue level not ignoring if blocks?

Posted: 20 Dec 2020 17:44
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: