With
From Free Pascal wiki
Revision as of 07:48, 21 March 2019 by Djzepi (talk | contribs) (Created page with "{{With}} The reserved word <syntaxhighlight lang="pascal" enclose="none">with</syntaxhighlight> allows a shortened spelling of records. It is on...")
The reserved word with
allows a shortened spelling of records. It is only used in conjunction with the do
reserved word.
Example:
// Definition of the record
type
TreRecord = record
strValue: string;
intValue: integer;
dblValue: double;
end;
var
reRecord: TreRecord; // Create the record
begin
...
// standard notation:
reRecord.strValue := 'Test';
reRecord.intValue := 5;
reRecord.dblValue := 4.2;
// When used with
with reRecord do
begin
strValue := 'Test';
intValue := 5;
dblValue := 4.2;
end;
...
end;