Please enable JavaScript to view this site.

A-Shell Reference

Binding a dynstruct definition to a dynstruct variable is a one-line operation, once the dynstruct has been defined and the variable declared…

map1 status,i,4      ! status variable

map1 ds, dynstruct   ! dynstruct variable 

 

status = Fn'Dynst'Bind("ST_TEST", ds) 

if status < 0 then <error>

 

As in the previous example, instead of using the MX_DYNSTRUCT call directly, here we used a wrapper function from fndynst.bsi in SOSLIB:[907,10], mainly to isolate us from possible changes in the implementation of the underlying mechanism. Using the MX_DYNSTRUCT directly would look like this:

map1 status,i,4      ! status variable

map1 ds, dynstruct   ! dynstruct variable 

 

xcall MIAMEX, MX_DYNSTRUCT, DYNOP_BIND, status, "ST_TEST", ds 

if status < 0 then <error>

 

Once the dynstruct definition has been bound to the dynstruct variable ds, the variable will have same size as the defined structure (ST_TEST) and can be copied to/from traditional structure variables of the same type, or X,0 variables. The following assumes that ds was defined and bound as show above.

map1 test1, ST_TEST  ! traditional structure 

 

test1 = ds           ! copy from DYNSTRUCT var to traditional structure 

ds = test1           ! or vice versa

 

To copy a bound dynstruct variable and its bound definition to another dynstruct variable that has not yet been bound, use the MX_DYNSTRUCT DYNOP_COPY or its wrapper function.