Page 2 of 2 <12
Topic Options
#214117 - 2022-04-29 06:05 PM Re: (NA) Re: Issue with Array not ignoring empty lines [Re: Glenn Barnas]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Just one more thing about this - it's not a ReadProfileString issue, it's a DATA issue. If you loaded a file - a set of lines - and then split it into an array of lines, you'd have the exact same issue - if the file contained a final line terminator, you'd have an empty final element. The only real difference is that we know that ReadProfileString ALWAYS returns the final line terminator, so we can simply snip it off. When reading a file, we'd need to first check whether the last char was a line terminator and remove it only if it was.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#214118 - 2022-04-29 06:24 PM Re: (NA) Re: Issue with Array not ignoring empty lines [Re: Glenn Barnas]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
I think we're all clear on what's going on, and why the extra trim/left is needed. The issue in my opinion is mostly lack of documentation. The guide simply says "If this parameter is empty, all key names in the section specified by section are returned".

(1) I wouldn't expect to have to split it by chr(10) going off just that text. Only way anyone would know, is to look at previous examples, or to display the return as a full string and guess if it's chr(10) or chr(13).

(2) I still wouldn't expect it to include the extra chr(10) at the end. This just adds the requirement of an additional unnecessary data massaging function in my opinion. No other enum functions return an extra element (I know those are arrays and not a string, but same concept).

As I stated above, I only suggest Left() over Trim() because if there happens to be an intentional space at the beginning or end of a key name (unlikely but possible), it would get trimmed off resulting in error. You could also do Left($string, Len($string)-1) if it makes you feel better. But not sure what you're referring to with the Left($string, -1) being a golf mechanism. The kix doc says "Specifying a negative value will cause Left to return the number of characters equal to the total length of the string minus the value specified". Nothing magical there. It is indeed clearly documented.

Top
#214120 - 2022-04-30 04:58 PM Re: (NA) Re: Issue with Array not ignoring empty lines [Re: ShaneEP]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Ok- my apology! I memorized the manual - um, gulp - roughly 20 years ago? I don't recall seeing that, and my not-even-close-to-idetic memory didn't recall that!

The documentation definitely needs to clarify the format.

I'm 100% against changing this in the code because the format is NL Terminated and changing this to make it actually delimited would break every application that's properly processed the output, resulting in breaking the last key-name value.
_________________________
Actually I am a Rocket Scientist! \:D

Top
#214122 - 2022-04-30 06:23 PM Re: (NA) Re: Issue with Array not ignoring empty lines [Re: Glenn Barnas]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Before I say I'm vehemently opposed to this, I would like to know what Ruud had specifically in mind.
Top
#214123 - 2022-05-02 12:49 AM Re: (NA) Re: Issue with Array not ignoring empty lines [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
 Quote:
my apology! I memorized the manual - um, gulp - roughly 20 years ago
I totally understand! I didn't even remember how the readprofilestring() returned data until this week. And I couldn't tell you how many times I've used it successfully in the past.

Top
#214141 - 2022-06-26 02:53 PM Re: (NA) Re: Issue with Array not ignoring empty lines [Re: ShaneEP]
Robdutoit Offline
Hey THIS is FUN
***

Registered: 2012-03-27
Posts: 363
Loc: London, England
I would concur that Ruud should decide how to proceed.

I don't mind either way, whether the function is changed or whether the documentation is updated to make people aware of the empty space issue. It's irrelevant whether the function is technically correct and the issue is Data - what is relevant is what programmers are expecting to get when using the function.

Judging by the fact that many experienced programmers are being caught out by this, clearly demonstrates the need to update the documentation or change how the function works.

Top
#214160 - 2022-09-12 03:47 PM Re: (NA) Re: Issue with Array not ignoring empty lines [Re: Robdutoit]
Ruud van Velsen Moderator Offline
Developer
*****

Registered: 1999-05-06
Posts: 391
Loc: Amsterdam, The Netherlands
Short update on this (while working on the final version of 4.69): I'm going to leave this as-is. The 4.69 beta actually has a fix for it, but I agree this is iffy as it may break existing scripts.

If there's a pressing reason, we can revisit in a future update.

Thanks for the input!

Top
Page 2 of 2 <12


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 366 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.052 seconds in which 0.023 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org