If/fi: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 2 | - | ||
| 3 | - | ||
| 1 | + | `If` [[Keyword/fi|avainsana]] edeltää ehtoa jota seurattava [[Then|then]] ja lause (statement). Siinä voi olla myös [[Else/fi|else]] lause. | |
| 4 | 2 | ||
| 5 | 3 | ## `If then` | |
| 6 | - | ||
| 4 | + | ||
| 5 | + | ``` pascal | |
| 7 | 6 | if condition | |
| 8 | - | ||
| 9 | - | ||
| 7 | + | then true_statement | |
| 8 | + | else false_statement; | |
| 10 | 9 | ``` | |
| 11 | 10 | ||
| 12 | - | ||
| 13 | - | ||
| 14 | - | ||
| 11 | + | Yllä olevan `condition` on [[Boolean/fi|boolean]] tyyppinen ehto joka tuottaa [[True|true]] tai [[False|false]] arvon. Koodissa siirrytään `true_statement` jos `condition` tuottaa arvon `true`. Koodissa siirrytään `false_statement` suoritukseen jos `condition` tuottaa arvon `false`. Käännösaikainen virhe syntyy jos `condition` ei tuota `boolean` tyyppistä arvoa. | |
| 15 | 12 | ||
| 16 | 13 | ### Monia lauseita `if then` haarassa | |
| 17 | 14 | ||
| 18 | - | ||
| 19 | - | ||
| 15 | + | Jos tarvitaan kahta tai useampaa lausetta `true_statement` tai `false_statement` niin se saadaan kokoamalla ne [[Begin/fi|begin]]` … `[[End/fi|end]] [[Block|lohkoon]] (koottu lause). | |
| 16 | + | ||
| 17 | + | ``` pascal | |
| 20 | 18 | if boolean_condition then | |
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - | ||
| 19 | + | begin | |
| 20 | + | statement_zero; | |
| 21 | + | statement_one; | |
| 22 | + | statement_two; | |
| 23 | + | end; | |
| 26 | 24 | ``` | |
| 27 | 25 | ||
| 28 | - | ||
| 29 | - | ||
| 30 | 26 | ## Katso myös | |
| 31 | 27 | ||
| 32 | - | ||
| 33 | - | ||
| 34 | - | ||
| 35 | - | ||
| 36 | - | ||
| 37 | - | ||
| 28 | + | - Official documentation: [Reference guide: § “The `If..then..else` statement”](https://www.freepascal.org/docs-html/ref/refsu57.html) | |
| 29 | + | - [[Basic Pascal Tutorial/Chapter 3/IF|IF]], Tao Yue, Basic Pascal Introduction | |
| 30 | + | - [[;/fi|If lause ja puolipiste]] | |
| 38 | 31 | ||
| 39 | 32 | --- | |
| 40 | - | ||
| 33 | + | *From the Free Pascal wiki, page "If/fi", as it stood on 2023-01-25 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).* |
