[fpc-devel] TStrings Add(array of string)

Andrew Haines AndrewD207 at aol.com
Sat Mar 31 20:27:50 CEST 2012


I was thinking about TStrings possibly having an overloaded function Add
or AddStrings where the argument is an array of string?

procedure Add(strs: array of string); overload;
or
procedure AddStrings(strs: array of string); overload;

Specifically I want this for TProcess.Parameters. since it's a bit of a
pain to type
Proc.Parameters.Add('-Arg1');
Proc.Parameters.Add('Arg1_Value');
Proc.Parameters.Add('-Arg2');
Proc.Parameters.Add('Arg2_Value');
Proc.Parameters.Add('-Arg3');
Proc.Parameters.Add('Arg3_Value');

even "with Proc.Parameters do begin Add(n); ... end; " is a bit ugly
when parameters have arguments.

when I could type:

Proc.Parameters.Add(['-Arg1', 'Arg1_Value']);
Proc.Parameters.Add(['-Arg2', 'Arg2_Value']);
Proc.Parameters.Add(['-Arg3', 'Arg3_Value']);

or even

Proc.Parameters.Add(['-Arg1','Arg1_Value','-Arg2','Arg2_Value','-Arg3',
'Arg3_Value']);

A less generic alternative would be adding a procedure to TProcess
AddArgs(args: array of string);

Is this a good idea?

If yes then I can create a patch.



Regards,

Andrew



More information about the fpc-devel mailing list