Storing records in associative arrays
// Storing records in associative arrays
type
TPerson = record
Age: Integer;
City: String;
end;
var directory: array [String] of TPerson;
var p: TPerson;
p.Age := 28;
p.City := 'New York';
directory['John'] := p;
p.Age := 32;
p.City := 'London';
directory['Emma'] := p;
// Accessing fields
PrintLn('John lives in ' + directory['John'].City);
PrintLn('Emma is ' + IntToStr(directory['Emma'].Age) + ' years old.');
// Updates
var updateJohn := directory['John'];
updateJohn.City := 'San Francisco';
directory['John'] := updateJohn;
PrintLn('John moved to ' + directory['John'].City);
John lives in New York Emma is 32 years old. John moved to San Francisco