If/fi: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: If/fi
| Old | New | Line | |
|---|---|---|---|
| 1 | + | `If` [[Keyword/fi|avainsana]] edeltää ehtoa jota seurattava `[[Then|then]]` ja lause (statement). Siinä voi olla myös `[[Else/fi|else]]` lause. | |
| 2 | + | ||
| 3 | + | ||
| 4 | + | ||
| 5 | + | ## `If then` | |
| 6 | + | ``` | |
| 7 | + | if condition | |
| 8 | + | then true_statement | |
| 9 | + | else false_statement; | |
| 10 | + | ``` | |
| 11 | + | ||
| 12 | + | 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. | |
| 13 | + | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + | ### Monia lauseita `if then` haarassa | |
| 17 | + | ||
| 18 | + | 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). | |
| 19 | + | ``` | |
| 20 | + | if boolean_condition then | |
| 21 | + | begin | |
| 22 | + | statement_zero; | |
| 23 | + | statement_one; | |
| 24 | + | statement_two; | |
| 25 | + | end; | |
| 26 | + | ``` | |
| 27 | + | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + | ## Katso myös | |
| 31 | + | ||
| 32 | + | * Official documentation: [Reference guide: § “The `If..then..else` statement”](<https://www.freepascal.org/docs-html/ref/refsu57.html>) | |
| 33 | + | * [[Basic Pascal Tutorial/Chapter 3/IF|IF]], Tao Yue, Basic Pascal Introduction | |
| 34 | + | * [[;/fi|If lause ja puolipiste]] | |
| 35 | + | ||
| 36 | + | ||
| 37 | + | **Keywords:** [[Begin|begin]] — [[Do|do]] — [[Else|else]] — [[End|end]] — [[For|for]] — [[If|if]] — [[Repeat|repeat]] — [[Then|then]] — [[Until|until]] — [[While|while]] | |
| 38 | + | ||
| 39 | + | --- | |
| 40 | + | *From the Free Pascal wiki, page "If/fi", as the Internet Archive kept it on 2025-03-22. 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).* |
