Difference between revisions of "If/fi"

From Lazarus wiki
Jump to navigationJump to search
m (Fixed syntax highlighting)
m (Text replacement - "Object Pascal Introduction" to "Basic Pascal Introduction")
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, Object Pascal Introduction
+
* [[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}}

Revision as of 03:30, 29 March 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 beginend lohkoon (koottu lause).

if boolean_condition then
begin
	statement_zero;
	statement_one;
	statement_two;
end;


Katso myös


Keywords: begindoelseendforifrepeatthenuntilwhile