Difference between revisions of "If and Then"
From Free Pascal wiki
Jump to navigationJump to search (what error? Suggest removing the entire sentence actually) |
(use specific documentation link) |
||
Line 3: | Line 3: | ||
This [[Keyword|keyword]] precedes a condition, must be followed by [[Then|then]] and may optionally be followed by [[Else|else]]. | This [[Keyword|keyword]] precedes a condition, must be followed by [[Then|then]] and may optionally be followed by [[Else|else]]. | ||
− | |||
− | |||
== If then == | == If then == | ||
Line 33: | Line 31: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | == Documentation == | ||
+ | Official documentation: [http://www.freepascal.org/docs-html/ref/refsu58.html#x163-18500013.2.3] | ||
{{Keywords}} | {{Keywords}} | ||
[[Category:Pascal]] | [[Category:Pascal]] | ||
[[Category:Control Structures]] | [[Category:Control Structures]] |
Revision as of 06:04, 22 July 2016
│
English (en) │
This keyword precedes a condition, must be followed by then and may optionally be followed by else.
If then
if condition
then true_statement
else false_statement;
Condition is a Boolean expression that evaluates to true or false. true_statement is executed if condition evaluates to true. false_statement is executed if condition evaluates to false. An error (What error? Run-time? Compile-time? What number? An exception perhaps? Please fix this) occurs if condition does not evaluate to a boolean value.
More statements in "if then" statement
If you need two or more statements for true_statement or false_statement, place them within a begin ... end Block.
if boolean_condition then
begin
statement_one;
statement_two;
statement_three;
end;
Documentation
Official documentation: [1]
Keywords: begin — do — else — end — for — if — repeat — then — until — while