How to finalize record passed through the untyped parameter of a function?

Can I pass "any" record type to my procedure ?

Many times I used "records" with strings.

  TR = record
    a: string;
    b: string;

To clear them, I need to write:

FillChar(R, SizeOf(R), #0);

The question is that how to I pass any kind of records to clear it ?

For this I got this hint: "Expression needs no initialize/finalize".

procedure ClearRecord(var R);
  FillChar(R, SizeOf(R), #0);

Thanks for every info!


Do not make it overly complicated. If you don't want to write a two-liner to clear the record, consider declaring:

Const TR_Empty: TR = ();

and use it:

R := TR_Empty;

And as commented by others, a generic procedure to do this is not worth the effort.

If you would have Delphi-2009 or newer, this code is valid for clearing a record:

R := Default(TR);

Need Your Help

How to add ripple effect to preferences in android?

android android-preferences listpreference rippledrawable

I am working on adding ripple effect when the preference is touched (selected). I have customized my preference by extending the ListPreference. I have tried to set the ripple effect programmatical...

Generate a data entry form dynamically from XSD including validation rules

winforms xsd data-entry xsd-validation

Is there anything around that can read an XSD schema and dynamically create a (Windows C#) data entry form? It would also need to read the type definitions and use them to validate the data entered...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.