Page 1 of 1

[fixed] Bug in foreach

Posted: 15 Jun 2023 00:35
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!

Re: Bug in foreach

Posted: 15 Jun 2023 09:16
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; }

Re: [fixed] Bug in foreach

Posted: 15 Jun 2023 12:09
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!

Re: [fixed] Bug in foreach

Posted: 15 Jun 2023 12:27
by admin
Such inconsistencies are inevitable in systems that evolve over time. Ask evolution.

Re: [fixed] Bug in foreach

Posted: 15 Jun 2023 14:59
by LittleBiG
And that's why I asked for something to support us with syntax somehow. Anyhow. :whistle: Went unnoticed.

viewtopic.php?p=203542