# Arrays of Dynstructs
> [HTML Version](arraysofdynstructs.htm)
As noted above in [Declare a DYNSTRUCT Variable](declare_a_dynstruct.htm.md), the dynstruct type currently only supports mapped scalar variables; no arrays, mapped or dimx. However, as also noted, you can work around this limitation by copying freely between dynstructs and arrays of traditional structures or X variables. In this example, we retrieve instances of ST\_TEST structures—defined in the example [Define a Dynstruct from a String](define_a_dynstruct.htm.md)—from a function, copying each to an array of type X that was previously dimensioned to match the size of ST\_TEST. Then we reverse the operation, copying elements out of the array back into the scalar dynstruct variable to print the members.
map1 dsdef\$,s,0 \! string to hold definition source
map1 fields,i,2 \! # fields (signed to allow error codes)
map1 stsize,b,4 \! size of the structure
map1 errmsg\$,s,100 \! error messages
map1 ds, DYNSTRUCT \! var to contain the dynstruct ST\_TEST
\! assume dsdef\$ string already built to define ST\_TEST (see first example)
\! now define it and get the size
fields = Fn'Dynst'Define(dsdef\$,stsize,"ST\_TEST",errmsg\$)
if fields > 0 then
dimx testarray(0), X, stsize, auto\_extend \! array to match dynstruct size
do while
ds = Fn’Get’Structure’Data\$("ST\_TEST") \! get data into the ds from somewhere
i += 1
testarray(i) = ds \! copy it into our unformatted array
loop
\! now reverse process, copying from the X array to our ds var
do while i > 0
ds = testarray(i)
? ds.sku
? ds.price.retail
? ds.notes(1)
? ds.@fname
\! etc
Loop
Endif