Sign in to follow this  

Ellipsis function arguments in Delphi

This topic is 4585 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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".

Share this post


Link to post
Share on other sites
Thank you :) That made it really easy to understand:D And it worked too:)

Share this post


Link to post
Share on other sites

This topic is 4585 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this