×
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.
We're kind of talking about two different things here.
My pointer warning was aimed at those who mistakenly believe that fields being consecutive in a record is a guarantee that they will be consecutive in memory - and that is a dangerous assumption. Use of a pointer to the first field in the sequence under these circumstances is dangerous and error prone.
So how to do it safely? You can crate a DS listing in order just the fields you need, therefore guaranteeing their sequence in memory OR you define a DS via ExtName to hold the record and then the fields are also consecutive in memory.
So - having defined a DS there are basically now two ways to define an array over the fields.
The first is by using a pointer to base the array with the pointer set to the address of the first of the array fields. The only downside to this approach is that a lot of RPG programmers are unfamiliar with pointer usage and may not understand what is happening.
The second method is to use the POS keyword to specify that the array starts at a particular position. The downside to this is that you have to hard code the position. As a result it is error prone because a change in the size of preceding field would affect the value. This however is a method that would be more obvious in intent to Joe Average RPGer.
The intent of the %POS BIF is that by referencing a field name you are avoiding problems caused by changes in field size etc. So you can use the most RPG-like solution without the danger.
There are other possible uses for %POS but this was the impetus for requesting it.
Jon Paris
www.partner400.com
www.SystemiDeveloper.com
On Jun 15, 2018, at 3:54 PM, Dan <dan27649@xxxxxxxxx> wrote:
Jon, forgive my ignorance. I saw that you warned against using a pointer
to mark the beginning of an array per Craig's comment in Alan's OP based on
his experience that he'd seen that an array of fields that appear in
sequence in the definition may not appear that way in the input buffer, so
I am unsure why you think that a %POS BIF would fix that. It just seems to
me to be an easier way to define what is essentially a pointer. What am I
missing?
- Dan
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link: http://amzn.to/2dEadiD
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.