|
No it cannot. This is a common misconception. They never change the layout. They create new layouts and add new fields to those new layouts.
That's not true. They add fields to existing layouts at least as often as they add new layouts.
The real truth is that they send you a variable with a length. You need to USE THAT VARIABLE rahter than just assume what the length will be. It's really that simple.
The problem is, when you post code like this: D MyArray S 10A Dim(1500) D BASED(pArray) C eval pArray = CrtUsrSpcPtr()What you're saying in that instance is that each element of the list that IBM sends you through the API will always be 10 bytes long. Even though they send you a variable that says how long it is, you STILL code "10A" on the array definition.
That's just wrong, and there's a HUGE chance that it'll break compatibility.
That's why QSORT is a better solution for this! Because the length of each element can be a variable -- you can use the variable that the API passes you rather than hard-coding the element length to "10A" which would be the only real solution if you wanted to use SORTA.
If you absolutely MUST hard code a length, and you absolutely MUST use SORTA because you'll jump through hoops forever just to avoid QSORT, then you should use the approach that Jim Wiant suggested. In that situation, you're sorting an array of your own devising rather than one provided by IBM, and therefore you won't have a chance of breaking anything.
But, IMHO, the code to sort with QSORT would be both faster and simpler.
In some rare cases, they do add one or two additional fields to the end of the data structure, but since they also return the length of that data structure in the BytesReturned subfield, if you're a good programmer, you'd check that value anyway.
I'd agree with you if we weren't talking about the list apis...
APIs are meant to NOT break on future releases. That's why my RPG xTools haven't blow up once due to an IBM API change during the 5 releases they've been available.
You're absolutely right that APIs are meant to not break in future releases, and that's exactly why they pass you the length of the element, and expect you to use it instead of hard-coding it.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.