i need to declare an array with user-defined dimension. This array is inside a pretty big program and change to a list can be pretty a problem.
Now my array is declared like this:
Buffer: array[0..myCostant * 2] of Byte;
and myCostant is, like it says, an already defined constant.
Now i need to use a variable, getting something like this:
Buffer: array[0..myVar * 2] of Byte;
but i can’t use variables inside array definition.
How i can solve this without changing my array in something else?
This variable is upper-bounded so can i declare array with this max size and reduce it with another instruction?
You should use dynamic arrays:
Alternatively, you can use a static array of the known upper-bound length and record the current ‘meaningful’ length of the array in a variable, say
CurrentLength.Then you can replace, for instance,
by