Of course, declare it in a block as follows:
procedure prog is arraySize : Integer := 0; type myArray is array(Integer range <>) of Float; begin -- Get Array size from user. put_line("How big would you like the array?"); get(arraySize); declare theArray : myArray(0..arraySize); begin for I in 0..arraySize Loop theArray(I) := 1.2 * I; end Loop; end; end prog;
or pass arraySize as an argument to a routine and declare and use it in that routine:
procedure Process_Array (arraySize : Integer) is theArray : myArray(0..arraySize); begin for I in arraySize'Range Loop theArray(I) := 1.2 * I; end Loop; end;
This is just illustrative (and not compiled :-) since you need to deal with things like invalid array size, etc.
source share