Please enable JavaScript to view this site.

A-Shell Reference

Rewritten February 2022

In order to bind a Dynamic Structure, the structure definition (i.e. the DEFSTRUCT) must be known at run time. This can be accomplished in one of two ways:

Call MX_DYNSTRUCT (DYNOP_INFO) to reprocess the DEFSTRUCT source code.
Arrange for the compiler to embed the desired DEFSTRUCT definitions into the RUN at compile time.

The first method is perhaps the most flexible, but has the disadvantage of requiring that the source code be available at run time. The second method increases the size of the RUN file somewhat, but has the advantage of eliminating the need for the source code at run time.

Structure definitions to be embedded may be identified by one of the following methods:

Specifying individual structure definitions to be embedded:

DEFSTRUCT st_foo

    ...

ENDSTRUCT

++pragma EMBED_DEFSTRUCT st_foo

 

Each EMBED_DEFSTRUCT pragma identifies a single DEFSTRUCT, which must already have been seen by the compiler, for embedding.

Enclosing a series of DEFSTRUCTs in a pair of EMBED_DEFSTRUCT_BEGIN and _END pragmas:

++pragma EMBED_DEFSTRUCT_BEGIN

    ...

++pragma EMBED_DEFSTRUCT_END

 

Any DEFSTRUCTs between the _BEGIN and _END pragmas will be embedded. You can have multiple such _BEGIN and _END blocks within a program.

Implicit embedding:

The .BINDSTRUCT statement will cause the definition of the referenced structure to be embedded. For example:

DEFSTRUCT ST_FOO

    map2 tender,s,10

    ...

ENDSTRUCT

map1 ds, DYNSTRUCT

map1 bar, ST_FOO

 

.BINDSTRUCT ds, bar    ! ST_FOO definition will be embedded

 

In addition, any defined structure instance passed to a function which receives it as a DYNSTRUCT will be embedded.  Building on the above example, ...

bar.tender = "Joe"

call Fn'Dive(ds=bar)   ! ST_FOO will be embedded (because of how fn'foo receives it)

...

 

function Fn'Dive(ds as DYNSTRUCT)

    ? "Hi , I'm "; ds.tender        !  ds'tender = "Joe" (implicit binding)

endfunction

 

History

2022 February, A-Shell 6.5.1711, compiler edit 967:  Feature added to A-Shell.