Difference between revisions of "If/fi"
(Created page with "{{If}} <code>If</code> avainsana edeltää ehtoa jota seurattava <code>then</code> ja lause (statement). Siinä voi olla myös <code>else</code>...") |
m (Fixed syntax highlighting) |
||
Line 7: | Line 7: | ||
== <code>If then</code> == | == <code>If then</code> == | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=pascal> |
if condition | if condition | ||
then true_statement | then true_statement | ||
Line 24: | Line 24: | ||
niin se saadaan kokoamalla ne <code>[[Begin|begin]] … [[End|end]]</code> [[Block|lohkoon]] (koottu lause). | niin se saadaan kokoamalla ne <code>[[Begin|begin]] … [[End|end]]</code> [[Block|lohkoon]] (koottu lause). | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=pascal> |
if boolean_condition then | if boolean_condition then | ||
begin | begin |
Revision as of 11:13, 17 February 2020
│
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, Object Pascal Introduction
- If lause ja puolipiste
Keywords: begin — do — else — end — for — if — repeat — then — until — while