Runtime enhancement—experimental: Allow passing global or module-scope DIMX array of X,0 elements by reference to a function. This is a logical extension of the array-by-reference feature added in edit 1389 (see below). For example:
dimx ARY(0),X,0,auto_extend
...
call Add'Items'To'Array( ARY() ) ! pass ARY() by reference to function
...
procedure Add'Items'To'Array( a() as x0) ! rcv array by reference
p = .extent( a() ) + 1
for i = p to q
a(i) = <some variable length string or binary data>
next i
endprocedure
Notes
• | The array must have been defined at the global or module-scope (private) level, rather than locally within a function. This is to ensure that the contents remain valid when referenced within another scope—i.e. a called routine. |
• | Currently this only works for X,0 (and not S,0) variables. The restriction may be lifted, but there is no particular need since variable length X variables are practically interchangeable variable length S variables anyway. The main distinction between X and S has to do with whether bytes past the first null are part of the variable, but this isn't really a factor when loading string data into dynamic X variables, since the variable size would be trimmed to eliminate any bytes after the trailing null anyway. |