foreach-bug ?

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
autocart
Posts: 1422
Joined: 26 Sep 2013 15:22

foreach-bug ?

Post by autocart »

1) create a new EMPTY txt file.
2) run this code:

Code: Select all

$fileText = readfile(inputfile(<curpath>, "txt", "Choose an empty txt file."));
  foreach($line, $fileText, "<crlf>", , "empty")
  {
    echo $line;
  }
3) admire the bug ;-)

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

Re: foreach-bug ?

Post by admin »

What bug?

autocart
Posts: 1422
Joined: 26 Sep 2013 15:22

Re: foreach-bug ?

Post by autocart »

alright,...
according to the help file there should be a message.
instead i get a scripting error with the scripting error box.

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

Re: foreach-bug ?

Post by highend »

It's a scripting error message, not a messagebox
One of my scripts helped you out? Please donate via Paypal

autocart
Posts: 1422
Joined: 26 Sep 2013 15:22

Re: foreach-bug ?

Post by autocart »

aha, well, the help file could be clearer on this ... but now I know. thx.

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

Re: foreach-bug ?

Post by admin »

autocart wrote:according to the help file there should be a message.
Not just a message, an "error message". And that's what you get. :)

autocart
Posts: 1422
Joined: 26 Sep 2013 15:22

Re: foreach-bug ?

Post by autocart »

well, at least I was right with the question mark in the title.

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

Re: foreach-bug ?

Post by admin »

:biggrin:

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: foreach-bug ?

Post by bdeshi »

[let me try probably invent a bug from thin air]
foreach reference remarks wrote:The separator defaults to "|" (pipe), but can be set to anything, also multi-character strings.
Since <an empty thing> is a subset of <anything>, So the separator can be an empty string. Therefore, this script should be able to loop through the characters in a string by setting the separator to empty. Which is not what happens.

Code: Select all

::$string='string'; foreach($letter, $string, ''){ echo $letter; }
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

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

Re: foreach-bug ?

Post by admin »

I take this as a wish rather than a bug, and I Iike it. Coming...

Filehero
Posts: 2734
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: foreach-bug ?

Post by Filehero »

Sammay, a char-iterator is really a cool idea. :tup:

Post Reply