Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Static and Dynamic Arrays
◄Summary► ◄Details► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
Static and Dynamic Arrays
■ Storage for arrays can be set aside when the program is compiled or when
the program is run, depending on whether the array is static or dynamic:
• Static arrays have storage set aside when the program is compiled.
• Dynamic arrays have storage set aside when the program is run. Storage
used by dynamic arrays can be eliminated when the program is running to
free memory for other uses.
■ In a SUB or FUNCTION statement that is not declared static, all arrays
are dynamic. See: ◄FUNCTION Statement► ◄SUB Statement►
■ Arrays declared using REDIM are dynamic arrays. See: ◄REDIM Statement►
■ You can use the $STATIC and $DYNAMIC metacommands to control how array
storage is allocated. However, the $STATIC metacommand cannot force
arrays to be static in a procedure not already declared static. In such
a procedure, all arrays are dynamic.
See: ◄$DYNAMIC Metacommand► ◄$STATIC Metacommand►
■ In some cases, you can allocate more space for strings by replacing static
arrays with dynamic arrays or by using variable-length string arrays
stored in far memory.
■ In compiled programs, the space for static arrays is allocated from
DGROUP, an area where strings are stored. On the other hand, dynamic
arrays and variable-length string arrays in far memory do not take any
space in DGROUP; they are stored as far objects and require far addresses.
See: ◄Array Storage Summary►