With

This is an old revision of With, edited by Djzepi at . The current revision is 132157.

Created page with "{{With}} The [[Reserved word|reserved word]] <syntaxhighlight lang="pascal" enclose="none">with</syntaxhighlight> allows a shortened spelling of [[Record|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;