× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Tommy,

s0300Ptr=s0300Ptr+%Size(SPLF0300)

Where s0300Ptr is set to the original offset just add the %size of the
DS returned.

The List APIs (including QUSLSPL) do not return the entries in fixed positions of the user space. The documentation states that these positions are variable -- and the API passes you a variable that indicates the start of the data, how many entries there are, and how far apart these entries are.

The emphasis in the above paragraph should be on "variable". While it's true that IBM doesn't usually change these positions except when a release changes, they'd be well within their rights to change them at any time.

For example, perhaps the entries would be a different distance apart, depending on the values of the input parameters. Or maybe the distance between each entry would change, based on a PTF.

The problem with your code example is that you've got that distance hardcoded in your program, and you're ignoring what the system tells you.

I'm referring ot the following statement:

  s0300Ptr=s0300Ptr+%Size(SPLF0300)

%size() is a hard-coded value. It's set at compile time, and won't ever change no matter what you do.

It's not any more difficult to use a variable for the offset instead of the size of your data structure! Assuming that the entry size field is in a variable called EntrySize you'd code:

  s0300Ptr=s0300Ptr+EntrySize

So my question is.... why do it wrong? Even if you don't mind fixing it with each release upgrade or PTF or whatever else breaks your code, how is it saving you anything to type "%size(SPLF0300)" instead of
"EntrySize"?

So this is the rule of thumb: When an API sends you an offset, size or displacement, don't ignore it and hard-code the position. Use the value that the API sent you.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.