Use StrJoin to add items to the end of an array.
|
Pas2JS pascal source code
var
a, b: array of string;
c: array [1..2] of string = ['e', 'f'];
begin
b := ['c', 'd'];
Writeln(StrJoin(b, ',')); // c,d
a.Add('a', 'b');
Writeln(StrJoin(a, ',')); // a,b
Writeln(StrJoin(b, ',')); // c,d
a.Add(b, 'e', 'f');
Writeln(StrJoin(a, ',')); // a,b,c,d,e,f
b.Clear;
a.Add(b, a);
Writeln(StrJoin(a, ',')); // a,b,c,d,e,f,a,b,c,d,e,f
//---------------------
a.Add(b, c);
Writeln(StrJoin(a, ',')); // a,b,c,d,e,f,a,b,c,d,e,f,e,f
b.Clear;
a.Add(b, []);
Writeln(StrJoin(a, ',')); // a,b,c,d,e,f,a,b,c,d,e,f,e,f
var a = [], b = [],
c = ["",""],
c = ["e", "f"];
b = ["c", "d"].slice();
WriteLn((b).join(","));
a.push("a", "b");
WriteLn((a).join(","));
WriteLn((b).join(","));
a.pusha(b).pusha(["e", "f"]);
WriteLn((a).join(","));
b.length=0;
a.pusha(b).pusha(a);
WriteLn((a).join(","));
/* --------------------------- */
a.pusha(b).pusha(c.slice(0));
WriteLn((a).join(","));
b.length=0;
a.pusha(b).pusha([]);
WriteLn((a).join(","));
/* OUTPUT
c,d
a,b
c,d
a,b,c,d,e,f
a,b,c,d,e,f,a,b,c,d,e,f
a,b,c,d,e,f,a,b,c,d,e,f,e,f
a,b,c,d,e,f,a,b,c,d,e,f,e,f
*/