Ellipsis function arguments in Delphi

Started by
1 comment, last by Afr0m@n 18 years, 9 months ago
Is there a symbol for doing something equivalent of ellipsis function arguments ("...") in Delphi? Google doesn't give me anything sensible, and neither does the Delphi7 manual:\ And could someone also please take the time to explain what it does? I don't find it easy to understand the Visual Studio manual on that part, to say it mildly.
_______________________Afr0Games
Advertisement
Well, the ellipsis in C is used to pass a variable amount of arguments at the end of the parameter list, but with no other information about them(type,number,etc...). For instance, it is used in printf:

printf("Print Numbers:%d %d %d",1,2,3)

as you see, you use the format string in the beginning to give additional information(you pass 3 arguments of type integer).

I haven't worked with Delphi since ver.5, but IIRC there wasn't an exact equivalent, but you could do pretty much the same using "array of const":

procedure SPrintF(formatstr:string;args:array of const);
begin
//Do stuff here...
end;

And you call the function like this: SPrintF('Number:%d %d %d',[1,2,3]);
It passes an array of type TVarRec, which is essentially variants.
The "Format" Delphi function does pretty much what SPrintF does, and uses "array of const".
Thank you :) That made it really easy to understand:D And it worked too:)
_______________________Afr0Games

This topic is closed to new replies.

Advertisement