Can you do that for fields in an existing copybook?

On Sun, Feb 17, 2013 at 11:36 AM, David Andrews <d...@lists.duda.com> wrote:

> On Sat, 2013-02-16 at 16:14 -0500, zMan wrote:
> > If this was supposed to be asking "What is it that's awkward to do in
> > COBOL?", try calculating the offset between two data elements.
>
> It's possible.  Not pretty, but IMO beats resorting to an assembly
> language subroutine.
>
> 01  POINTER-ARITHMETIC.
>     05  FIELD1-ADDRESS  POINTER.
>     05  FIELD1-ADDRESSD REDEFINES FIELD1-ADDRESS
>                         PIC 9(8) COMP-5.
>     05  FIELD2-ADDRESS  POINTER.
>     05  FIELD2-ADDRESSD REDEFINES FIELD2-ADDRESS
>                         PIC 9(8) COMP-5.
>
>     SET FIELD1-ADDRESS TO ADDRESS OF FIELD1.
>     SET FIELD2-ADDRESS TO ADDRESS OF FIELD2.
>     COMPUTE FIELD-OFFSET = FIELD2-ADDRESSD - FIELD1-ADDRESSD.
>
> --
> David Andrews
> A. Duda & Sons, Inc.
> david.andr...@duda.com
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>



-- 
zMan -- "I've got a mainframe and I'm not afraid to use it"

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to