For complex variables, “overwrite” or “extend” can be declared in assignments. As with simple variables, “overwriting” then means that the old contents of the relevant elements are deleted before they are assigned new contents. “Extend” has no effect on the contents of existing elements; they are not deleted.
When variable contents are deleted explicitly with the FREE-VARIABLE command, note the effects on complex variables and variable containers.
Basically, it must be remembered that a FREE-VARIABLE applied to an array, a list or a dynamic structure deletes and removes all elements. In contrast, a FREE-VARIABLE applied to an element of an array, of a list or of a dynamic structure only deletes and removes this one element.
Variables that have been initialized using the DECLARE-CONSTANT command cannot be released by means of FREE-VARIABLE.
Lists
If FREE-VARIABLE is applied to a list, all list elements are deleted and removed. The declaration is retained.
If the FREE-VARIABLE refers to a list element or a section of list elements, then the list is renumbered after the deletion and removal of the list elements because the list may not contain gaps in the numbering.
Arrays
If FREE-VARIABLE is applied to an array, all array elements are deleted and removed; the declaration is retained.
If FREE-VARIABLE is applied to an array element, this element is deleted and removed.
If the array elements are themselves structures, the elements of these structures are deleted but the structure declaration is retained. In the case of dynamic structures, this means that the declaration TYPE = *STRUCTURE(*DYNAMIC) is retained; for static structures, it means that the element declarations are retained (the same applies to lists).
Structures
If FREE-VARIABLE is applied to a static structure, the elements are deleted; the structure declaration, i.e. the declaration of its elements, is retained. Correspondingly, if FREE-VARIABLE is applied to an element of a static structure, the element’s contents are deleted.
If FREE-VARIABLE is applied to a dynamic structure, the contents of the elements in this structure are deleted and all elements are removed. If FREE-VARIABLE is applied to an element in a dynamic structure, this element is removed. If the structure element itself is a complex variable, all elements of this variable (and all other subelements that may be dependent on it) are also removed.
Variable containers
Variables can be linked with other variables or job variables as variable containers. If, in such a link, the variable container is a variable, the contents of the container variable are deleted as specified in the FREE-VARIABLE command.
If the variable container is a job variable, the programmer can determine whether the job variable is deleted together with the variable when the FREE-VARIABLE command is issued. In this case, “deleting a job variable” means that the job variable’s catalog entry is deleted.