× 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.



I'm not sure this is a situation where pointers will do much for you
that you can't do with an array.  Because RPG has pass by reference, any
parm you pass to a procedure that can be changed by the procedure is
really a pointer to the variable in the calling routine. 

RPG pointer arithmetic is by bytes.  Say you have a "record" 10 bytes
long and you have a list of them.  The beginning of the list has an
address contained in a pointer called phead.  You have a variable called
work based on a pointer called pwork.  To traverse the list you start by
assigning the value of phead to pwork.  Work will contain the data found
at the address in pwork.  To go to the next record add 10 to
pwork--pwork += 10.  You need to know how to detect the end of the list.
That depends on how you implemented the list build.  You may know the
number of "records," the address of the last one, or have a marker value
in the last record...

There are situations where pointers come in handy in RPG.  Most of the
ones I've run across involve list APIs or other things that use user
spaces. A lot of the APIs that have parms described as pointers are
happy with a variable passed by reference.  I would guess that some
people have implemented various kinds of tree structures or linked lists
in RPG, but I've never done anything that sophisticated.  Pointers make
dynamic memory allocation possible which makes it possible to change the
dimension of arrays, among other things.

Java doesn't have pointers at all.  The people who designed it thought
that pointers were too easy to abuse and/or misunderstand. 


 

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Tom Smith
Sent: Thursday, February 17, 2005 3:02 PM
To: Rpg Forumn
Subject: Pointer suggestion

Hello everyone,

I would like to write a subproc that will return several hundred records
from a table file. The fields I wish to return are defined as follows:
Keys(20), Value1(25), value2(200).

I know in writing a standard program I could pass parms defined as
arrays, but I think that this could be done using pointers. I have used
limited pointer logic with existing subprocs.

Could anyone provide some help in defining and traversing through the
returned information.

Thanks

--
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.


*****************************
NOTICE:
All e-mail sent to or from this e-mail address will be received or otherwise 
recorded by
The Sharper Image corporate e-mail system and is subject to archival, 
monitoring,
and review by and/or disclosure to Sharper Image security and other management.
This message is intended only for the use of the addressee and may contain 
information
that is privileged and confidential.

The contents of this message may contain personal views which are not the views 
of The Sharper Image.
If you are not the intended recipient, dissemination of this communication is 
prohibited.
*****************************


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.