End/fr: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: End/fr
| Old | New | Line | |
|---|---|---|---|
| 1 | + | Le [[Keyword/fr|mot-clé]] **end** termine un [bloc](</index.php?title=Block/fr&action=edit&redlink=1> "Block/fr \(page does not exist\)") d'instructions commencé par le mot-clé [[Begin/fr|begin]] ou [[Case/fr|case]], termine la déclaration des [champs](</index.php?title=field/fr&action=edit&redlink=1> "field/fr \(page does not exist\)") d'un [[Record/fr|enregistrement]], ou ferme une construction [try](</index.php?title=Try/fr&action=edit&redlink=1> "Try/fr \(page does not exist\)") .. [finally](</index.php?title=Finally/fr&action=edit&redlink=1> "Finally/fr \(page does not exist\)") or [try](</index.php?title=Try/fr&action=edit&redlink=1> "Try/fr \(page does not exist\)") .. [except](</index.php?title=Except/fr&action=edit&redlink=1> "Except/fr \(page does not exist\)"). Il est aussi utilisé pour fermer une [[Unit/fr|unité]] qui n'a pas de code d'initialisation. | |
| 2 | + | ||
| 3 | + | Par exemple: | |
| 4 | + | ``` | |
| 5 | + | procedure Proc1; | |
| 6 | + | ||
| 7 | + | var a,b: integer; | |
| 8 | + | ||
| 9 | + | begin | |
| 10 | + | (..) | |
| 11 | + | end; | |
| 12 | + | ``` | |
| 13 | + | ||
| 14 | + | L'instruction _end_ est l'une des exceptions à la règle qui veut que chaque instruction doit être suivie par un point-virgule. En effet, l'instruction précédant exactement l'instruction _end_ ne requiert pas de point-virgule. | |
| 15 | + | ||
| 16 | + | Il termine aussi un fichier source Pascal, auquel cas il est suivi du point plutôt que du [[;|point-virgule]] (dans l'exemple ci-dessous, le dernier point-virgule est facultatif): | |
| 17 | + | ``` | |
| 18 | + | program Proc2; | |
| 19 | + | var | |
| 20 | + | SL: TStrings; | |
| 21 | + | begin | |
| 22 | + | SL := TStringlist.Create; | |
| 23 | + | try | |
| 24 | + | (..) | |
| 25 | + | finally | |
| 26 | + | SL.Free; | |
| 27 | + | end; | |
| 28 | + | end. | |
| 29 | + | ``` | |
| 30 | + | ||
| 31 | + | Pour une unité sans bloc d'initialisation, END est utilisé pour indiquer la fin de l'unité: | |
| 32 | + | ``` | |
| 33 | + | unit detent; | |
| 34 | + | uses math; | |
| 35 | + | ||
| 36 | + | procedure delta(r:real); | |
| 37 | + | ||
| 38 | + | implementation | |
| 39 | + | ||
| 40 | + | procedure delta; | |
| 41 | + | begin | |
| 42 | + | ||
| 43 | + | ... | |
| 44 | + | ||
| 45 | + | end; | |
| 46 | + | ||
| 47 | + | ... | |
| 48 | + | ||
| 49 | + | (* Note: Pas d'instruction '''begin''' *) | |
| 50 | + | ||
| 51 | + | end. | |
| 52 | + | ``` | |
| 53 | + | ||
| 54 | + | Il ferme aussi un [[Record/fr|enregistrement]]: | |
| 55 | + | ``` | |
| 56 | + | Type | |
| 57 | + | ExampleRecord = Record | |
| 58 | + | Values: array [1..200] of real; | |
| 59 | + | NumValues: Integer; { tient le nombre actuel de point dans le tableau } | |
| 60 | + | Average: Real { tient la moyenne des valeurs dans le tableau } | |
| 61 | + | End; | |
| 62 | + | ``` | |
| 63 | + | ||
| 64 | + | ||
| 65 | + | **Mots-clés:** [[Begin/fr|begin]] — [[Do/fr|do]] — [[Else/fr|else]] — end — [[For/fr|for]] — [[If/fr|if]] — [[Repeat/fr|repeat]] — [[Then/fr|then]] — [[Until/fr|until]] — [[While/fr|while]] | |
| 66 | + | ||
| 67 | + | --- | |
| 68 | + | *From the Free Pascal wiki, page "End/fr", as the Internet Archive kept it on 2025-01-14. 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).* |
