With/de: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: With/de
| Old | New | Line | |
|---|---|---|---|
| 1 | + | Zurück zu den [[Reserved words/de|reservierten Wörtern]]. | |
| 2 | + | ||
| 3 | + | Das reservierte Wort with erlaubt eine verkürzte Schreibweise bei Records und Objekten. | |
| 4 | + | ||
| 5 | + | Beispiel: | |
| 6 | + | ||
| 7 | + | ``` pascal | |
| 8 | + | // Definition des Datensatzes | |
| 9 | + | type | |
| 10 | + | TDatensatz = record | |
| 11 | + | strWert: string; | |
| 12 | + | intWert: integer; | |
| 13 | + | dblWert: double; | |
| 14 | + | end; | |
| 15 | + | ||
| 16 | + | var | |
| 17 | + | recDatensatz: TDatensatz; // Erstellen des Datensatzes | |
| 18 | + | ||
| 19 | + | begin | |
| 20 | + | ... | |
| 21 | + | ||
| 22 | + | // Standardschreibweise: | |
| 23 | + | recDatensatz.strWert := 'Test'; | |
| 24 | + | recDatensatz.intWert := 5; | |
| 25 | + | recDatensatz.dblWert := 4.2; | |
| 26 | + | ||
| 27 | + | // Die Schreibweise mit with ist nicht nur kürzer, sondern hat auch einen Geschwindigkeitsvorteil | |
| 28 | + | with recDatensatz do | |
| 29 | + | begin | |
| 30 | + | strWert := 'Test'; | |
| 31 | + | intWert := 5; | |
| 32 | + | dblWert := 4.2; | |
| 33 | + | end; | |
| 34 | + | ... | |
| 35 | + | end; | |
| 36 | + | ``` | |
| 37 | + | ||
| 38 | + | --- | |
| 39 | + | *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](/wiki-contact).* |
