#1 2024-05-01 22:42

bdpq
Member
Registered: 2015-11-05
Posts: 9

New function to Concatenate Arrays?

I have been using a rather complicated function to concatenate 2 arrays into one. Is it possible to have a built-in function that does this in future releases?

It would be nice to allow '+' to work on TWideStringArray directly so that
Array1 + array2 + ... can be allowed?

Thanks for consideration!

Offline

#2 2024-05-02 14:13

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,380

Re: New function to Concatenate Arrays?

The current Pascal Script implementation is not capable of overloading the '+' operator to make it work with TWideStringArray or any other custom types.

However, we can add built-in functions to offer this functionality. Keep an eye on the next development version.

Offline

#3 2024-05-07 10:20

bdpq
Member
Registered: 2015-11-05
Posts: 9

Re: New function to Concatenate Arrays?

this is what I am using now in my ever-growing includes. tongue  Just copying the values as it loops through.  Really looking forward to a built-in function!

function concatArrays(const r1, r2:TWideStringArray):TWideStringArray;
var i: Integer;
begin
	SetLength(result, length(r1) + Length(r2));
	for i := 0 to length(r1)-1 do result[i] := r1[i];
	for i := 0 to length(r2)-1 do result[i + length(r1)] := r2[i];	
end;

Offline

Board footer

Powered by FluxBB