MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » January 2002

Re: How to Define input fields into Array (Barbara's final answer!)



fixed

Barbara, Rob, Denis, Buck

Thank you Barbara -

I'm copying this to the RPG400 list for final archival reference and answer
to all our questions.

So, the answer is:   Redefine your input file as an external data
structure, or simply list the offending array elements in a data structure,
and all our dreams will come true!  (re: using pointers and based() for
array redefines)

Thanks to all,

Rick

From: bmorris@ca.ibm.com
Subject: Re: How to Define input fields into Array
To: midrange-l@midrange.com
Date: Fri, 11 Jan 2002 11:53:09 -0500
Reply-To: midrange-l@midrange.com


>From: rob@dekko.com
>Date: Thu, 10 Jan 2002 16:56:54 -0500
>
>     fARRAYFILE IF   E           K DISK    RENAME(ARRAYFILE:ARRAYREC)
>     f                                     INFDS(HIYA)
>     d MyArray         s                   like(ary1) dim(3)
>     d                                     based(pMyArray)
>     d pMyArray        s               *   inz(%addr(ary1))

Rob, as Rod guessed, you can't count on ARY1, ARY2 and ARY3 being
contiguous.  To ensure they are contiguous, define an externally-described
data structure:

     d               e ds                  extname(ARRAYFILE)

>From: "Richard B Baird" <rbaird@esourceconsulting.com>
>Date: Fri, 11 Jan 2002 08:23:02 -0500
> ...
>the technique I was told about involved having the fields described ONLY
in
>an external data structure 'D' spec.  I assume that the %addr technique
>still works if the data is actually described by the "I"nput specs
>generated by an input file?

Richard, you need a data structure for sure, whether or not you have
I specs or O specs.  (Either an externally-described DS, or a pgm-described
one that just lists the fields without the types.)

Just remember that I and O specs are really descriptions of move operations
between the I/O buffer and the fields.  They're also be used for
definitions,
if there isn't an explicit definition, but the definition isn't identical
to
the I spec.  For example, if you have a zoned (5,2) on an I spec, the
compiler
will define a packed (5,2) for you.

Barbara Morris







Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot 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 here. If you have questions about this, please contact