[fpc-pascal] Access Violation When SetLength(DynArray, Value)
James Richters
james.richters at productionautomation.net
Sat Sep 10 01:41:36 CEST 2022
>With FPC 3.2.0 and newer you can do "Concat(MyArray, [TheNewElement])" or (if modeswitch ArrayOperators is active) "MyArray := MyArray + [TheNewElement]".
I have a lot of arrays of records, but I just build the record into the array elements, like this:
SetLength(MathArray,Length(MathArray)+1);
MathArray[High(MathArray)].Variable:=NewVariable;
MathArray[High(MathArray)].Formula:=NewEquation;
Could either of the methods mentioned work directly with something like this or would I have to build the record first and do:
MyRecord.Variable:=NewVariable;
MyRecord.Formula:=NewEquation;
MathArray:= MathArray+ MyRecord;
I thought I would make my own IncArray() function:
Procedure IncArray(Var TheArray);
Begin
SetLength(TheArray,Length(TheArray)+1);
End;
But I get a 'Type Mismatch' Any ideas how this could be done? Is this even possible without specifying the exact type of array?
James
More information about the fpc-pascal
mailing list