Solved - continue level not ignoring if blocks?

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Post Reply
highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: continue level not ignoring if blocks?

Post by admin »

Indeed. Should work correctly in next beta.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @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: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @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: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

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;}
				}
		}

klownboy
Posts: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

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:

admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @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: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

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. :)

klownboy
Posts: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

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:

Post Reply