Hi. I'm not sure if Delphi can do this, but I'm trying to create a variable that I can create once in the code and can't be changed, after its created. On the surface, it looks like I want a const, but I'm trying to create a variable which is an array that will only have its size defined at run-time.
myBaseArray : myArrayType
temp_i : integer;
myArrayType = array[1..nElements] of double;
myArray : myArrayType;
myCounter : integer;
myMaxCounter = 10;
for myCounter := 1 to myMaxCounter do
myArray := myBaseArray;
// some code to then do some further stuff with myArray
for temp_i := 1 to nElements do myBaseArray[temp_i] := 1.0;
Now this is not my actual code, but is illustrative of what I'm trying to do. In this scenario, nElements is read in from a file (i.e. not a const) and I want to make sure that in myTestProcedure, nothing can change myBaseArray.
If anyone knows how I can create this myBaseArray in such a way that nothing can accidentally edit it later (without passing it in as a function argument, as there will be dozens of arrays like this, going into dozens of different procedures and don't want to have to pass hundreds of arguments around all the time!), that would be great
1 Year Ago
Related Article:Empty Object Variables
is a solved Pascal and Delphi discussion thread by DelphiGuy that has 2 replies and was last updated 1 year ago.