Sign in Join
Wiki copytemporary

Revision 1 of 1, by Trev on 3-4-2020. The page as it is now.

With/de

Zurück zu den reservierten Wörtern.

Das reservierte Wort with erlaubt eine verkürzte Schreibweise bei Records und Objekten.

Beispiel:

pascal
// Definition des Datensatzes
type
  TDatensatz = record
    strWert: string;
    intWert: integer;
    dblWert: double;
  end;

var
   recDatensatz: TDatensatz; // Erstellen des Datensatzes

begin
  ...

  // Standardschreibweise:
  recDatensatz.strWert := 'Test';
  recDatensatz.intWert := 5;
  recDatensatz.dblWert := 4.2;

  // Die Schreibweise mit with ist nicht nur kürzer, sondern hat auch einen Geschwindigkeitsvorteil
  with recDatensatz do
  begin
    strWert := 'Test';
    intWert := 5;
    dblWert := 4.2;
  end;
  ...
end;

From the Free Pascal wiki, page "With/de", as it stood on 2020-03-04 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.