Please enable JavaScript to view this site.

A-Shell 6.5 Development Notes

Beginning with compiler edit 821, a DEFSTRUCT may now include a MAP1 statement as the first member of the structure. The result is equivalent to the combination of the DEFSTRUCT without the MAP1 and the contained MAP statements (including the MAP1) without the DEFSTRUCT. This is useful when migrating legacy code from traditional MAP1-style structures to DEFSTRUCT-style structures, eliminating the need to either convert them all at once or to maintain parallel versions of the structure layouts.

Eliminating the need to maintain parallel copies of mapped structure layouts was, after all, one of the primary motivations for the DEFSTRUCT concept in the first place.

For example, say you have a common include file with this record layout:

MAP1 CUST                    ! mapped customer record

    MAP2 ID,S,8

    MAP2 NAME,S,30

    ...

 

The equivalent structure definition and mapped instance would be:

    DEFSTRUCT ST_CUST        ! customer structure

        MAP2 ID,S,8

        MAP2 NAME,S,30

        ...

    ENDSTRUCT

    MAP1 CUST,ST_CUST        ! mapped instance of customer structure

 

The only problem with the above is that all existing references any of the members of the CUST record would need to be converted (e.g. from ID to CUST.ID, etc.) If you didn't want to go through all your programs at once, you instead could leave the traditionally mapped CUST record intact and rename the new structure version, i.e.:

DEFSTRUCT ST_CUST            ! customer structure

    MAP2 ID,S,8

    MAP2 NAME,S,30

    ...

ENDSTRUCT

MAP1 SCUST,ST_CUST           ! mapped instance of customer structure

 

Now you would have two equivalent record layouts, CUST (ID, NAME, ...) SCUST (SCUST.ID, SCUST.NAME, ...). The main problem with that, aside from the resulting lack of syntax consistency, is that if you modify the layout, you have to remember to modify both versions (the MAP1 CUST version and the DEFSTRUCT ST_CUST version).

This new compiler enhancement eliminates that problem by using a single set of MAP statements to generate both the structure definition and the traditional mapped variable definition, i.e.

DEFSTRUCT ST_CUST

    MAP1 CUST

    MAP2 ID,S,8

    MAP2 NAME,S,30

            ...

    ENDSTRUCT

    MAP1 SCUST,ST_CUST       ! mapped instance of customer structure

 

Now the traditional record variable CUST and the new structure version SCUST are guaranteed to always have identical formats.

Note that this is purely a compiler enhancement and has no effect on runtime compatibility for the compiled programs. So you may want to use this version of the compiler even if continuing to use the 6.4 runtime.