End/fi: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: End/fi
| Old | New | Line | |
|---|---|---|---|
| 1 | + | [[Keyword|avainsana]] `end` päättää kokonaisuuden. Se esintyy useissa eri paikoissa: | |
| 2 | + | ||
| 3 | + | - merkitä moduulin lopun, eli esim. [[Program/fi|ohjelma]], [[Unit/fi|käännösyksikkö (unit)]] tai [[Library|library]] | |
| 4 | + | - merkitä [[Block|lohkon]] tai ohjeistuksen lopun | |
| 5 | + | - joko [[Begin/fi|begin]] tai | |
| 6 | + | - [[Asm|asm]] aloitetun | |
| 7 | + | - sulkea joitakin kielirakenteita: | |
| 8 | + | - [[If and Then|if … then … end]] tai | |
| 9 | + | - [[Case/fi|Case]] … [[Of|of]] … `end` rakenteen lopetus, mutta myös | |
| 10 | + | - [[Try, Except and Finally|try … except … finally … end]] (poikkeukset) | |
| 11 | + | - lopettaa tietyt [[Type/fi|type]] määrittelyt, kuten [[Object/fi|object]], [[Record/fi|record]] ja [[Class/fi|class]] | |
| 12 | + | ||
| 13 | + | Esimerkiksi: | |
| 14 | + | ||
| 15 | + | ``` pascal | |
| 16 | + | procedure proc0; | |
| 17 | + | var | |
| 18 | + | a, b: integer; | |
| 19 | + | begin | |
| 20 | + | … | |
| 21 | + | end; | |
| 22 | + | ``` | |
| 23 | + | ||
| 24 | + | Pääsääntö on että jokaisen `end` sanan perässä on oltava [[Semicolon|puolipilkku]]. `End` sanaa edeltävä lause ei vaadi puolipistettä. | |
| 25 | + | ||
| 26 | + | Sitä käytetään myös Pascal-moduulin lopettamiseen, jolloin sitä seuraa [[period|piste]], joka ei siis ole puolipilkku (alla olevassa esimerkissä viimeinen puolipilkku on vapaaehtoinen): | |
| 27 | + | ||
| 28 | + | ```delphi | |
| 29 | + | program proc1; | |
| 30 | + | var | |
| 31 | + | SL: TStrings; | |
| 32 | + | begin | |
| 33 | + | SL := TStringlist.create; | |
| 34 | + | try | |
| 35 | + | … | |
| 36 | + | finally | |
| 37 | + | SL.free; | |
| 38 | + | end; | |
| 39 | + | end. | |
| 40 | + | ``` | |
| 41 | + | ||
| 42 | + | `end` käytetään ilmaisemaan käännösyksikön (unit) lopun: | |
| 43 | + | ||
| 44 | + | ``` pascal | |
| 45 | + | unit detent; | |
| 46 | + | uses math; | |
| 47 | + | ||
| 48 | + | procedure delta(r:real); | |
| 49 | + | ||
| 50 | + | implementation | |
| 51 | + | ||
| 52 | + | procedure delta; | |
| 53 | + | begin | |
| 54 | + | ||
| 55 | + | ... | |
| 56 | + | ||
| 57 | + | end; | |
| 58 | + | ||
| 59 | + | ... | |
| 60 | + | (* Huomaa: Ei vastaavaa '''begin''' lausetta *) | |
| 61 | + | ||
| 62 | + | end. | |
| 63 | + | ``` | |
| 64 | + | ||
| 65 | + | Se lopettaa [[Record/fi|record]] määrittelyn: | |
| 66 | + | ||
| 67 | + | ``` pascal | |
| 68 | + | Type | |
| 69 | + | ExampleRecord = Record | |
| 70 | + | Values: array [1..200] of real; | |
| 71 | + | NumValues: Integer; { holds the actual number of points in the array } | |
| 72 | + | Average: Real { holds the average or mean of the values in the array } | |
| 73 | + | End; | |
| 74 | + | ``` | |
| 75 | + | ||
| 76 | + | --- | |
| 77 | + | *From the Free Pascal wiki, page "End/fi", as it stood on 2022-08-06 after a change by Kai Burghardt, 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).* |
