I have a unit in which there are multiple variables that has to be same sized vectors.
However I do not know the length of this array before i parse the file.
So I want to have a dynamic array that is "global" for the whole unit and then i can
The code below shows the issue as well as the solution I have now. The solution I have now is to assign a maximum value to be the length of the array.
unit xyz;
interface
uses
abc
const
maxval=50;
type
vectorofdouble = [1...maxval] of double; // I want to change this to dynamic array
type
T_xyz = object
public
NP: integer;
private
var1: vectorofdouble;
var2: vectorofdouble;
public
number: integer;
var3: vectorofdouble;
private
procedure Create();
function func1(etc): integer;
public
procedure ReadFile(const FileName, inputs: string);
end;
implementation
procedure T_xyz.ReadFile();
////////
Read(F,np)
//SetLength(vectorofdouble, np) // DOES NOT WORK
for i := 0 to maxval // I DONT WANT TO LOOP UP TO MAXVAL
begin
var1[i] := 0
end;
procedure T_xyz.func1(etc);
////////
do stuff
for i := 0 to maxval // I DONT WANT TO LOOP UP TO MAXVAL
begin
var2[i] := 0
end;
end;
end.
SetLength. So, for instance,SetLength(var1, ...). By the way, what does OFlex stand for?