[fixed] Bug in foreach

Things you’d like to miss in the future...
Post Reply
PeterH
Posts: 2814
Joined: 21 Nov 2005 20:39
Location: Germany

[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.
Win11 Pro 23H2 Gerrman

admin
Site Admin
Posts: 63600
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: 2814
Joined: 21 Nov 2005 20:39
Location: Germany

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!
Win11 Pro 23H2 Gerrman

admin
Site Admin
Posts: 63600
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