// A procedure that displays a variable number of strings
procedure ShowCustomer(const fields: array of string);
var
i : Integer;
begin
// Display all fields passed - note : arrays start at 0
for i := 0 to Length(fields)-1 do
WriteLn(fields[i]);
WriteLn(sLineBreak); // #13#10
end;
procedure TForm1.W3Button11Click(Sender: TObject);
var John, Sarah : TCustomer1;
i : integer;
begin
// Set up the John's customer details
John.firstName := 'John';
John.lastName := 'Smith';
John.address1 := '7 Park Drive';
John.address2 := 'Branston';
John.address3 := 'Grimworth';
John.city := 'Banmore';
John.postCode := 'BNM 1AB';
// Set up John's sister similarly - simply copying the whole record
Sarah := John;
// And then changing the first name to suit
Sarah.firstName := 'Sarah';
// Now show the details of both customers
ShowCustomer([John.firstName, John.lastName,
John.address1, John.address2, John.address3,John.city,
John.postCode]);
ShowCustomer([Sarah.firstName, Sarah.lastName,
Sarah.address1, Sarah.address2, Sarah.address3,Sarah.city,
Sarah.postCode]);
end;
|