Difference between revisions of "If/fi"
m (Fixed syntax highlighting) |
m (bypass redirect to Basic Pascal Tutorial/Chapter 3/IF) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
{{If}} | {{If}} | ||
− | <code>If</code> [[Keyword|avainsana]] edeltää ehtoa jota seurattava <code>[[Then|then]]</code> ja lause (statement). | + | <code>If</code> [[Keyword/fi|avainsana]] edeltää ehtoa jota seurattava <code>[[Then|then]]</code> ja lause (statement). |
− | Siinä voi olla myös <code>[[Else|else]]</code> lause. | + | Siinä voi olla myös <code>[[Else/fi|else]]</code> lause. |
== <code>If then</code> == | == <code>If then</code> == | ||
− | <syntaxhighlight lang=pascal> | + | <syntaxhighlight lang="pascal"> |
if condition | if condition | ||
then true_statement | then true_statement | ||
Line 13: | Line 13: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | Yllä olevan <code>condition</code> on [[Boolean|boolean]] tyyppinen ehto joka tuottaa [[True|true]] tai [[False|false]] arvon. | + | Yllä olevan <code>condition</code> on [[Boolean/fi|boolean]] tyyppinen ehto joka tuottaa [[True|true]] tai [[False|false]] arvon. |
Koodissa siirrytään <code>true_statement</code> jos <code>condition</code> tuottaa arvon <code>true</code>. | Koodissa siirrytään <code>true_statement</code> jos <code>condition</code> tuottaa arvon <code>true</code>. | ||
Koodissa siirrytään <code>false_statement</code> suoritukseen jos <code>condition</code> tuottaa arvon <code>false</code>. | Koodissa siirrytään <code>false_statement</code> suoritukseen jos <code>condition</code> tuottaa arvon <code>false</code>. | ||
Line 22: | Line 22: | ||
Jos tarvitaan kahta tai useampaa lausetta <code>true_statement</code> tai <code>false_statement</code> | Jos tarvitaan kahta tai useampaa lausetta <code>true_statement</code> tai <code>false_statement</code> | ||
− | niin se saadaan kokoamalla ne <code>[[Begin|begin]] … [[End|end]]</code> [[Block|lohkoon]] (koottu lause). | + | niin se saadaan kokoamalla ne <code>[[Begin/fi|begin]] … [[End/fi|end]]</code> [[Block|lohkoon]] (koottu lause). |
− | <syntaxhighlight lang=pascal> | + | <syntaxhighlight lang="pascal"> |
if boolean_condition then | if boolean_condition then | ||
begin | begin | ||
Line 37: | Line 37: | ||
* Official documentation: [https://www.freepascal.org/docs-html/ref/refsu57.html Reference guide: § “The <code>If..then..else</code> statement”] | * Official documentation: [https://www.freepascal.org/docs-html/ref/refsu57.html Reference guide: § “The <code>If..then..else</code> statement”] | ||
− | * [[IF]], Tao Yue, | + | * [[Basic Pascal Tutorial/Chapter 3/IF|IF]], Tao Yue, Basic Pascal Introduction |
* [[;/fi#If lause ja puolipiste|If lause ja puolipiste]] | * [[;/fi#If lause ja puolipiste|If lause ja puolipiste]] | ||
{{Keywords}} | {{Keywords}} |
Latest revision as of 06:06, 25 January 2023
│
Deutsch (de) │
English (en) │
suomi (fi) │
français (fr) │
русский (ru) │
中文(中国大陆) (zh_CN) │
If
avainsana edeltää ehtoa jota seurattava then
ja lause (statement).
Siinä voi olla myös else
lause.
If then
if condition
then true_statement
else false_statement;
Yllä olevan condition
on boolean tyyppinen ehto joka tuottaa true tai 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.
Monia lauseita if then
haarassa
Jos tarvitaan kahta tai useampaa lausetta true_statement
tai false_statement
niin se saadaan kokoamalla ne begin … end
lohkoon (koottu lause).
if boolean_condition then
begin
statement_zero;
statement_one;
statement_two;
end;
Katso myös
- Official documentation: Reference guide: § “The
If..then..else
statement” - IF, Tao Yue, Basic Pascal Introduction
- If lause ja puolipiste
Keywords: begin — do — else — end — for — if — repeat — then — until — while