LOCATION

LOCATION returns a FIXED BIN value that specifies the byte location of x within the level-1 structure or union that has member x.

Read syntax diagramSkip visual syntax diagram
>>-LOCATION(x)-------------------------------------------------><

Abbreviation: LOC

x
Structure or union member name. If x is not a member of a structure or union, a value of 0 is returned. If x has the BIT attribute, the value returned by LOCATION is the location of the byte that contains x.

The value for x must not be subscripted.

LOCATION can be used in restricted expressions, with a limitation. The value for x must be declared before y if LOC(x) is used to set either of the following:

Under the CMPAT(V3) compiler option, LOCATION returns a FIXED BIN(63) value. Under all other CMPAT options, it returns a FIXED BIN(31) value.

Example

  dcl 1 Table static,
        2 Tab2loc fixed bin(15) nonasgn init(loc(Tab2)),
                    /* location is 0; gets initialized to 8  */
        2 Tab3loc fixed bin(15) nonasgn init(loc(Tab3)),
                    /* location is 2; gets initialized to 808 */
        2 Length fixed bin nonasgn init(loc(End)),
                    /* location is 4 */
        2 * fixed bin,
        2 Tab2(20,20)    fixed bin,
                    /* location is 8 */
        2 Tab3(20,20)    fixed bin,
                    /* location is 808 */

        2 F2_loc fixed bin nonasgn init(loc(F2)),
                    /* location is 1608; gets initialized to  1612 */
        2 F2_bitloc fixed bin nonasgn init(bitloc(F2)),
                    /* location is 1610; gets initialized to 1 */

        2 Flags,        /* location is 1612 */
          3 F1 bit(1),
          3 F2 bit(1),  /* bitlocation is 1 */
          3 F3 bit(1),
        2 Bits(16) bit, /* location is 1613 */
        2 End char(0);





Published: 23 December 2018