# .BINDSTRUCT

> [HTML Version](bindstruct.htm)

_Updated August 2022_

**.BINDSTRUCT ds, st**

**Parameters**

_ds_

an instance of a [DYNSTRUCT](mx_dynstruct.md) 

_st_

an instance of a [DEFSTRUCT](defstruct.md) 

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](structuredefinitionembedding.md)

•	[MX\_DYNSTRUCT](mx_dynstruct.md)

**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