Parker Hannifin
Program Flow
Code is executed sequentially, following the order in which it is
written. But based on some input, you can shift code execution
elsewhere in a program using conditional statements. Using
conditional statements, you can create code that tests for specific
conditions and repeats code statements.
The conditional statement provides a logical test—a truth
statement—allowing decisions based on whether the conditions are
met. In the code, you create an expression and test whether the
result is true.
You can divide conditional statements into two sub-categories,
selection and repetition.
NOTE: Each level (or nest) uses 4 bytes of memory. For more on
memory use, see How Much Memory?
Selection
The selection structure controls the direction of program flow. Think
of it as a branch in your program. When the conditions are met, the
program moves to a different block of code. AcroBASIC provides
the following conditional statements:
• IF/THEN
• IF/ELSE/ENDIF
• GOSUB
• GOTO
IF/THEN
Programs need to run code based on specific conditions. The
IF/THEN statement lets a program test for a specific condition and
respond accordingly.
The IF portion sets of the condition to test; if the condition proves
true, the THEN portion of the statement executes. If instead the
condition proves false, the THEN statement is ignored and program
execution moves on to the next statement.
NOTE: Enclose the condition being tested in parentheses.
Though the IF/THEN statement provides a single-line test, it can
execute multiple statements when the condition proves true. All the
statements must appear on a single line and be separated by a
space, colon, and another space.
Programming Basics 19