If avainsana edeltää ehtoa jota seurattava then ja lause (statement).
Siinä voi olla myös else lause.
If then
editif 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
editJos 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
edit- Official documentation: Reference guide: § “The
If..then..elsestatement” - IF, Tao Yue, Basic Pascal Introduction
- If lause ja puolipiste
Keywords: begin — do — else — end — for — if — repeat — then — until — while