[fixed] Bug in foreach

Things you’d like to miss in the future...
Forum rules
:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:

: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: 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: When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".

:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:
Post Reply
PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

[fixed] Bug in foreach

Post by PeterH »

Is it just me? Working with arrays *is* problem :masked:

The following code is kind of "super-compressed" from real code.

1) a ForEach() with an array. OK
2) behind that an unrelated ForEach with a list. Abend = :bug: !

Delete 1st foreach, or skip it (incl it's continue): 2nd ForEach is OK!

It seems "relicts" of array-ForEach destroy following list-ForEach! :shock:

Code: Select all

// Bug in ForEach(list) after ForEach(array)
   step;
   $agnr[0] = 'YYY';
   ForEach($agnr as $nr, 'e')  { continue; }

   $cmd = "aa<crlf>bb";
   ForEach($cmd, $cgrp, <crlf>, 'e')  { Continue; }
PS: good night!
Last edited by PeterH on 15 Jun 2023 12:05, edited 1 time in total.

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

Re: Bug in foreach

Post by admin »

Yes, something was not reset. :bug: Fix comes. :tup:

* * *

BTW (unrelated to the bug), looks like you got the positions wrong. Instead of

Code: Select all

ForEach($cmd, $cgrp, <crlf>, 'e')  { Continue; }
it should be

Code: Select all

ForEach($cgrp, $cmd, <crlf>, 'e')  { Continue; }

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: [fixed] Bug in foreach

Post by PeterH »

Thanks again: the bug is gone!

And thanks for the demonstration :biggrin:
That's why I often mock around for "simple, clear and unique logic"! (Though I didn't do here.)
ForEach(array) says (array as variable), while
ForEach(list) says (variable, list)
From the first moment I saw this I thought: bad! Not only for this, but also for "one stmt with syntax dependent from operands".

All these little things lead to unnecessary "How to use? Where's the help?"
And if you don't look - you'll often be wrong.
This time you were wrong.

So please excuse if I continue to mock "I think that's bad done".
Even if you think it's only a peanut.

And don't get me wrong: XY *is* a fine product :tup:

Have a nice day!

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

Re: [fixed] Bug in foreach

Post by admin »

Such inconsistencies are inevitable in systems that evolve over time. Ask evolution.

LittleBiG
Posts: 1848
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: [fixed] Bug in foreach

Post by LittleBiG »

And that's why I asked for something to support us with syntax somehow. Anyhow. :whistle: Went unnoticed.

viewtopic.php?p=203542

Post Reply