Description
"If" constructs are used to conditionally execute instructions. The
format of an "If" construct is:
IF <someconditional expression> then
<statement>;
An example of an "If" construct is:
If XAxis.ActualPosition > 2000 then
XBeyondLimit:=true;
The identation is a convention to improve readability. Although not required it is recommended.
If just one statement needs to be performed simply place that statement after the "then". However if several
statements need to execute then enclose the entire group inside a begin..end to create a compound statement. For example:
if XAxis.ActualPosition > 2000 then
begin
XAxisBeyondLimit:=true;
SignalAlarm;
AbortTask(Addr(XMovementTask));
end;
Some languages have an "Endif" to bracket an "If"
instruction. Pascal instead uses the idea of performing one statement after the IF which
can be a single statement or a compound statement which contains inside many individual statements.
"If" instructions may be nested to allow additional qualification:
if XAxis.ActualPosition > 2000 then
if YAxis.ActualPosition > 2000 then
begin
BothAxisBeyondLimits:=true;
SignalAlarm;
AbortTask(Addr(MovementTask));
end;