_DYNAMIC (type field)
The _DYNAMIC field qualifier is used to designate an array member inside a user TYPE definition as explicitly changeable in a program by using REDIM on that specific array member.
Syntax
Parameters
- lb and ub are the respective lower bound and upper bound indexes of the array.
- _DYNAMIC qualifies the array as explicitly changeable.
- Variable Type defines the datatype of the array elements. Note that some types may not be allowed for arrays.
- May also be the name of another user defined TYPE which may also contain array members, hence nested array constructs are possible.
Description
- This keyword can only be used for array members inside TYPE definitions.
- There's no connection or interaction with a globally used $STATIC or $DYNAMIC metacommand.
- The use of this keyword currently requires the $UNSTABLE:TYPEFIELDS metacommand until all issues around arrays in types have been fixed and stabilized.
Availability
-
none
-
v4.6.0
-
yes
-
yes
-
yes
Examples
- Example 1
$UNSTABLE:TYPEFIELDS TYPE TText text(0 TO 1) _DYNAMIC AS STRING END TYPE REDIM groups(0 TO 1) AS TText REDIM groups(0).text(0 TO 2) REDIM groups(1).text(1 TO 5) groups(0).text(2) = "Test" groups(1).text(5) = "QB64PE" PRINT groups(0).text(2) PRINT groups(1).text(5) REDIM _RETAIN groups(0).text(0 TO 6) REDIM _RETAIN groups(2) AS TText REDIM _RETAIN groups(2).text(1 TO 7) groups(0).text(6) = "Test 2" groups(2).text(7) = "QB64PE 2" PRINT groups(0).text(6) PRINT groups(2).text(7) |
- Example 2
$UNSTABLE:TYPEFIELDS TYPE TBuffer sample(0 TO 1) _DYNAMIC AS SINGLE END TYPE REDIM buffers(0 TO 1) AS TBuffer REDIM buffers(0).sample(0 TO 9) REDIM buffers(1).sample(1 TO 20) buffers(0).sample(5) = 1.5 buffers(1).sample(20) = 2.5 PRINT buffers(0).sample(5), LBOUND(buffers(0).sample), UBOUND(buffers(0).sample) PRINT buffers(1).sample(20), LBOUND(buffers(1).sample), UBOUND(buffers(1).sample) |
See also
- TYPE, _STATIC (type field)
- $STATIC (metacommand), $DYNAMIC (metacommand)
- Arrays, REDIM, ERASE
- $UNSTABLE (metacommand)