Updated March 2025
The binding operation associates a dynamic structure definition with a DYNSTRUCT variable, accomplished via one of the following methods.
map1 ds, DYNSTRUCT ! sample dynamic struct (used below)
map1 stvar, ST_SOME_STRUCT ! sample defstruct " "
map1 bar, ST_ANOTHER_STRUCT ! another sample defstruct " "
• | Explicit binding via MX_DYNSTRUCT: |
xcall MIAMEX, MX_DYNSTRUCT, DYNOP_BIND, status, dsname$, ds
• | Explicit binding via .BINDSTRUCT: |
.BINDSTRUCT ds, stvar
• | Implicit DYNSTRUCT by passing an instance of a defined structure to a function which receives it as a DYNSTRUCT: |
call Fn'Dive(ds=bar) ! ST_ANOTHER_STRUCT will be embedded (because of how Fn'Dive receives it))
...
function Fn'Dive(ds as DYNSTRUCT)
Implicit binding works even for parameters defined with the :OUTPUTONLY qualifier. The received DYNSTRUCT variable will be empty regardless of the default value, if any, but will be bound. For example:
defstruct st_cust
map2 id,b,4
map2 name,s,30
endstruct
map1 cust, st_cust
cust.id = 99
cust.name = "Jacob"
call fn'foo(ds=cust)
? cust.name ! will be "Finkleheimer"
end
function fn'foo(ds="" as dynstruct:outputonly)
? ds.name ! will be "" because of :outputonly
ds.name = "Finkleheimer" ! valid because ds auto-bound to st_cust
xputarg @ds
endfunction
See Also
History
2025 March, A-Shell 7.0.1770.0, compiler edit 1064: The :OUTPUTONLY qualifier no longer disables implicit binding. Prior to this update, the references to ds.name inside the function would have generated error 70 (invalid dynstruct reference) because the :outputonly would have defeated the automatic binding.