Sign in Join
Wiki copytemporary

With/de

Deutsch · English · Suomi · Русский

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.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.