|
I don't know if I would say cryptic, but it's more of a mindset. The API's follow their own (albeit sometimes a little weird) logic, but at least they are consistent (mostly). I think it's kind of like a marriage. You just accept some oddities, but it mostly works. JPW -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Holden Tommy Sent: Friday, 23 September 2005 12:52 To: RPG programming on the AS400 / iSeries Subject: RE: API- Userspace pointer Question Okay..I learned something today... Honestly I didn't know that the entry size was what that field contained in the generic header...(else I would be using it...) I would never advocate bad programming. I offered a solution to a question which has served me so far. I will be using the returned entry size from now on (especially since I know it's there..) That's just one of the "gotchas" of trying to learn APIs from IBM's documentation..I find them cryptic (is it only me???) Thanks for the lesson! Thanks, Tommy Holden -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement Sent: Thursday, September 22, 2005 4:05 PM To: RPG programming on the AS400 / iSeries Subject: RE: API- Userspace pointer Question 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. -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
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.