Arrays can also be allocated using
NEW, and this works in a very similar way to that outlined in the previous section.
The difference is that the size of the array must also be supplied, in both the use of
Of course, the size supplied to
END must be the same as the size supplied to the appropriate use of
All this extra effort also gains you the ability to create an array of a size which is not a constant (unlike variables of type
This means that the size supplied to
END can be the result of an arbitrary expression.
DEF a:PTR TO LONG, b:PTR TO myobj, s NEW a /* A dynamic array of LONG */ s:=my_random(20) NEW b[s] /* A dynamic array of myobj */ /* ...some other code... */ END a, b[s]
my_random function stands for some arbitrary calculation, to show that
s does not have to be a constant.
This form of
NEW can also be used as an expression, as before.
Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.