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



Thanks for that Paul. The example you provided was very explicit and
provided a clear-cut reason for using a pointer. But it seems both you
and Scott are correct. What was running through my mind was the overhead
of passing a buffer around. I thought a pointer might be more efficient.

I'll explain the scenario in a litle more detail as my first attempt may
have been confusing:

Program A loops through a number of files associated with an EDI
application.

The program will call one program for each file to manage the editing of
the fields in ach record.. 
So now we have a hierachy:


PROGRAM a 
   |
   |> Program B
   |      |
   |      |> sub-procedure x
   |      |> sub-procedure y 
   |      |> sub-procedure z  
   | 
   | 
   |> Program C
   |      |
   |      |> sub-procedure t 

Program B now manages the editing of each field in the record that
program A has read.
Each of the field edits is managed by a sub-procedure which is passed in
the field and returns a Boolean in the procedure name and an array of
error message ids as a return parameter. There is one procedure per
field. 

Program B needs the data in the record read by Program A so that the
procedure granularity can be at the field level, and a separate module
can be created for every file.

The original question was therefore concerned with not passing the
entire record, but rather, having access to the fields by mapping the DS
in program B to the address reference provided by the pointer to avoid
passing a buffer which must have some sort of overhead.

I appreciate your explanation of the pointer situation in a multi-tier
call. It makes perfect sense. But then Scott's answer is probably
correct too as my situation is only a 2 tier call, as long as there is
little overhead. Or am I being too paranoid about overhead?  Of course,
the parameter should be read only as all I'm doing is editing the
values.

I'm yet to code this up as I wanted to get the theoretical nuances
flushed out first. I'm sure I'll have more questions shortly. Thanks
again.

 
------Original Message-----
F|rom: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Paul Morgan
Sent: Tuesday, 4 October 2005 12:47 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: Passing a pointer as a parameter.


Mike,

It makes perfect sense to me to pass a pointer to a data structure.
I've found it useful to just pass a pointer to a subprocedure when all
that subprocedure is going to do is pass it on to another subprocedure.
You don't have to declare the data structure in every procedure it gets
passed through - just the procedure that has the data structure and the
procedure that is going to use it.

Declare a data structure in the subprocedure like your record layout and
as standalone field.  Included the BASED keyword on that datastructure
with the based pointer in that keyword the name of the pointer passed in
to the subprocedure.  Then you use the data structure as you would
normally and ignore the fact that it's being passed 'by address' using a
pointer.

Passing in the pointer to the record format might be tricky.  You'll
need a data structure in the calling procedure and use the %Addr BIF to
get the pointer to that data structure.  You can't use the %Addr BIF on
a record format name although using %Addr on the first field in the
record could be a hack around that (making an assumption that all record
fields are stored contiguously in the program which might be working
that way now but could change in the future).


Why don't you consider breaking up your edits into different routines?
Each routine would pass back an error indicator which you could use in
your main program.  You be passing in the required fields to the various
edit routines instead of passing in the whole record to one big huge
routine that does all the editing.

Paul

Paul Morgan
Senior Programmer Analyst - Retail
J. Jill Group
100 Birch Pond Drive, PO Box 2009
Tilton, NH 03276-2009
Phone: (603) 266-2117
Fax:   (603) 266-2333

Mike wrote

>I presume that I would include the record as a data structure in the 
>second program and somehow or other 'connectt' it to the pointer passed

>in, so that the DS layout was 'overlaid' to storage from the pointer 
>reference position.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.