Updated August 2022
.BINDSTRUCT ds, st
Parameters
ds
an instance of a DYNSTRUCT
st
an instance of a DEFSTRUCT
The .BINDSTRUCT statement binds the specified DYNSTRUCT variable (ds) to the structure definition corresponding to the specified DEFSTRUCT instance variable (st). Then it copies the data from the DEFSTRUCT instance to the DYNSTRUCT.
This would be equivalent to the following...
xcall MIAMEX, MX_DYNSTRUCT, DYNOP_DEF, status, src$, fields, stsize, dsname$
xcall MIAMEX, MX_DYNSTRUCT, DYNOP_BIND, status, dsname$, ds
ds = st
... except that the structure name (dsname$) is determined implicitly from the structure variable instance (st), and the src$ parameter is set to "" to extract the structure definition from the current RUN file directly.
Note that DEFSTRUCTs are embedded in the RUN file only under certain conditions. If not embedded by the compiler, you can embed them at run time using MX_DYNSTRUCT. See the links before for more details.
Also note that the second argument (the defstruct instance) may be a base array reference. For example:
.BINDSTRUCT ds, st()
In this case, the structure is bound to the DYNSTRUCT instance (ds), but no data is copied. However, once bound, you can then manually copy elements from the array, using the same binding, e.g.
.bindstruct ds, st() ! bind w/o copy
for i = .extent(st())
ds = st(i) ! copy, preserving prior binding
? ds,@fldname$ ! dynstruct deferred indirect ref
next i
See Also
• Structure Definition Embedding
History
2022 August , A-Shell 6.5.1718: Add option, as described above, allowing st to be a base array reference.
2022 February, A-Shell 6.5.1711: Function added to A-Shell