Please enable JavaScript to view this site.

A-Shell Development History

Navigation: Version 6.1/6.2, builds 1300-1428 > 1391 – 02 October 2014

Allow dynamic variables below the MAP1 level

Scroll Prev Top Next More

Compiler/runtime enhancement (edit 712) !EXPERIMENTAL - for testing only!

Allow dynamic variables (s,0 and x,0) below the MAP1 level. For example:

DEFSTRUCT ST_REC

    MAP2 SKU,S,10

    MAP2 DESCR,S,0      ! variable length!!

    MAP2 PRICE,F

ENDSTRUCT

 

This can be a useful technique for encapsulating data with variable-length components, but it creates an implicit linkage between the structure and the variable length elements that opens the door to various kinds of risks if not handled carefully. The size of the structure is fixed—the variable length field appears to have a fixed length of 16 bytes—but the contents of the variable length member are stored outside the structure, in the dynamic variable pool. The structure can be passed as a parameter to a function, and the variable length elements will remain intact, but at that point they should be treated as read-only. Both copies of the structure would link to the same variable-length text, but if that text is changed, only the current structure would remain properly linked to the updated text.

Writing the structure to a file would also make no sense; in that case, what would actually be written for the dynamic members would be their 16 byte descriptors, which would be useless outside the immediate context of the program.