Re: Fixed-Length strings vs. NUL-terminated strings

Patrik Schindler <[email protected]> Fri, 4 Jun 2021 14:32:14 +0200
Newsgroups gmane.comp.lang.as400.c
Message-ID <[email protected]>
Hello Chris,

Am 04.06.2021 um 14:21 schrieb Chris Hird <[email protected]>:

> Use a for() loop from position n to start of field until a non space is found.

Thanks! That's what I'll do. But I'm a bit surprised that there seem to be no APIs for that on a Platform IBM has been pushing to be webby. Maybe this knowledge has been lost because today, everything is done with SQL…

> Another option would be to have a separate field that stores the string length when written.

Since the original strings are fixed length, I don't see a way to get this fixed other than by looping over the individual fields' buffer, and set the byte immediately next to the first non-space character to NUL. Similar to your proposal. Since the buffer will be overwritten with the following _Rreadn anyway, I'll modify the original buffer. Might also save some CPU cycles on my 150. ;-)

Thanks again!

:wq! PoC

-- 
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/c400-l
or email: [email protected]
Before posting, please take a moment to review the archives
at https://archive.midrange.com/c400-l.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com