Array Dynamic (Copy method)



Array Dynamic (Copy method)
Pas2JS pascal source code
type TIntegers = array of Integer; var a1, a2: TIntegers; i: Integer; begin a1 := [1,2,3]; for i := a1.Low to a1.High do Writeln(a1[i]); // 1,2,3 Writeln(a1.Length); // 3 WriteLn('--------------'); a2 := a1.Copy(1); for i := a2.Low to a2.High do Writeln(a2[i]); // 2,3 Writeln(a2.Length); // 2 WriteLn('--------------'); a2 := a1.Copy; for i := a2.Low to a2.High do Writeln(a2[i]); //1,2,3 Writeln(a2.Length); //3 WriteLn('--------------'); try a2 := a1.Copy(3, 0); except on e: Exception do Writeln(e.Message); end; try a2 := a1.Copy(1, - 1); except on e: Exception do Writeln(e.Message); end; try a2 := a1.Copy(0, 4); except on e: Exception do Writeln(e.Message); end; try a2 := a1.Copy(-1, 2); except on e: Exception do Writeln(e.Message); end;