If I am trying to call a procedure which has a record type (not object) as a parameter, is it possible to somehow pass details of that parameter “inline” without having to declare a variable of that type first?
eg assume I have this simple record type:
type TMyRecord = record
AString: string;
AnInt: Integer;
end;
and this procedure declaration:
procedure MyProcedure(Rec: TMyRecord);
If I want to call MyProcedure do I have to declare a variable of type TMyRecord or can I do something like:
MyProcedure(TMyRecord("Test", 10));
That doesn’t work (XE2) (get a compiler error about it expecting a “)”).
So, can I do something like that? Or not possible.
Thanks
It is possible using the
advanced recordstructure.For more information about
advanced records, see the Records (advanced) section in Delphi help.This is a small prototype to see how it works in your case to preinitialize a record in a function/procedure call :
Looking at the Delphi RTL, see the definitions of the record types
TPointandTRectin unitsystem.types(XE2).They define some overloaded
Createconstructors, which are used in lots of places to preinitialize the record structures in function/procedure calls.