I assume that my question may already exist in SO knowledgebase and I just couldn't find it. In this case, please guide me to the origin and vote to close this one as a duplicate. It is about passing array parameters to a procedure.
The below case is simple, intuitive and working:
procedure MyProc(const A: array of ShortString);
begin
//
end
Now I can call MyProc
and directly pass strings to it:
MyProc(['no', 'trump', 'please']);
Now what if I declare a type of array of ShortString?
type
TMyArray = array of ShortString;
procedure MyProc(const A: TMyArray);
begin
//
end
Is there any way to execute MyProc
passing parameters of array type directly? I.e. using the same procedure call as above.
+bonus question:
type TMyRecord = record
param, value: ShortString
end;
procedure MyProc(const R: TMyRecord);
begin
//
end
Is there any technique to call a procedure and pass values of a type record? Something like (pseudocode):
MyProc((TMyRecord.param='aaa', TMyRecord.value='bbb'));
The reason I ask: I don't want to declare a variable and set it up. Instead I want to pass array/record values directly as a procedure parameter.
array of string
Code Insight stops functioning. An an alternative for this particular example I used short strings which do not stop the show. – Interface Unknown