What is the equivalent of SetLength using Oxygene? I'm trying to size an integer array.
var listIndexes: array of integer;
begin
setLength(listIndexes,5); // doesn't work
end;
Bill, the function Setlength does not exist in Delphi-Prism (you can use the namespace ShineOn.Rtl from ShineOn wich have a partial implementation of the Setlength function).
In delphi prism you can try this
type
IntegerArray = array of integer;
var listIndexes: IntegerArray;
listIndexes:=New IntegerArray(5);
or
var listIndexes: Array of Integer;
listIndexes:=New Integer[5];
UPDATE
Also, you can write your own SetLength
method SetLength(var myArray: Array of Integer; NewSize: Integer);
var
ActualLength: Integer;
begin
var DummyArray: &Array := &Array.CreateInstance(typeOf(Integer), NewSize);
if assigned(myArray) then
begin
ActualLength:= iif(myArray.Length > NewSize, NewSize, myArray.Length);
&Array.Copy(myArray, DummyArray, ActualLength);
end;
myArray := array of integer(DummyArray);
end;