Skip to Main Content
Mastering Delphi Programming: A Complete Reference Guide
book

Mastering Delphi Programming: A Complete Reference Guide

by Primož Gabrijelčič
November 2019
Beginner to intermediate content levelBeginner to intermediate
674 pages
15h
English
Packt Publishing
Content preview from Mastering Delphi Programming: A Complete Reference Guide

Cloning records

Making copy of a record is simple, because records are value types in Delphi, similar to integers, floating-point numbers, and booleans. We can just assign one variable of a record type to another and the compiler will make a copy:

var  a, b: TSomeRecord; begin  a.Initialize;  b := a;  // b now contains same data as aend;

There are limitations to this approach, and they are best explained with an example. In the Prototype folder of this chapter's code, you'll find the project PrototypeRecord, which demonstrates simplicity, and problems, with record cloning.

In the unit Prototype.Rec, you'll find the definition of a record type TCloneableRec that contains fields of different types: string, integer, two kinds of arrays, interface, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Delphi GUI Programming with FireMonkey

Delphi GUI Programming with FireMonkey

Andrea Magni
Delphi Cookbook - Third Edition

Delphi Cookbook - Third Edition

Daniele Spinetti, Daniele Teti

Publisher Resources

ISBN: 9781838989118Other