Eloquence Language Manual
6 Branching and Subroutines
Normal program execution is in sequential order from the lowest numbered line to the highest numbered line. Branching alters this process by transferring control to a statement which is out of the sequential flow. Branching is just one method of altering the normal flow of program execution. This chapter covers conditional and unconditional branching, looping, subroutines and branching using softkeys.
The following statements, functions, and commands are discussed in this chapter:
- GOTO
- Branches (unconditionally) to a specified program line.
- ON GOTO
- Branches to one of a list of specified program lines.
- IF THEN
- Branches or executes a statement upon a stated condition.
- FOR
- Defines the beginning of a FOR-NEXT loop.
- NEXT
- Terminates a FOR-NEXT loop.
- GOSUB
- Branches (unconditionally) to a subroutine.
- RETURN
- Terminates a subroutine and returns control to the main program.
- ON GOSUB
- Branches to one of a list of specified subroutines.
- SOFTKEYSET ON/OFF
- Statement to switch softkey set indicator on or off.
- ON KEY #
- Branches to a specified program sequence when the specified special function key is pressed.
- OFF KEY #
- Disables any previous ON KEY # statement for the corresponding key number.
- ON ERROR
- Branches to a specified program sequence when an error occurs.
- OFF ERROR
- Cancels any previous ON ERROR.
- DISABLE
- Prevents ON KEY # declaratives from interrupting program execution.
- ENABLE
- Reactivates ON KEY # declaratives.
- CURKEY
- Returns the value of the most recent interrupting condition, including softkeys, timed delay interrupts, and terminal input/output (TIO) interrupts.
- ON HALT
- Branches to a specified program sequence when BREAK is pressed.
- OFF HALT
- Cancels any previous ON HALT.
- INDENT
- Changes all program line indentation.
- ON SIGNAL
- Branches to a specified program sequence when SIGUSR1 signal is caught. For more detailed description of this and the two following functions,see chapter 14.
- OFF SIGNAL
- Cancel previous ON SIGNAL, see chapter 14.
- SEND SIGNAL
- Send SIGUSR1 signal to specified taskid, see chapter 14.
- ON KEYBD
- Arbitrary keys can be used as function keys.
- OFF KEYBD
- Cancel previous ON KEYBD.
Structured programming techniques improve the programming task via better program organization. A set of enhanced Eloquence statements is available with the Eloquence operating system to improve program readability.
- IF THEN ELSE
- States one of two statements to be executed depending upon the result of a conditional expression.
- WHILE . . . . . . END WHILE
- Repeats execution of a block of statements while a conditional expression remains true.
- LOOP . . . . . . . END LOOP
- Continually repeats a block of statements until a branch out occurs via an EXIT IF statement.
- REPEAT . . . . . UNTIL
- Repeats execution of a block of statements until a conditional expression becomes true.
- SELECT . . . . . END SELECT
- Allows branching to any of a set of CASE statements depending on the value of a conditional expression.
Chapter contents:
- Unconditional Branching
-
- Conditional Branching
-
- Looping
-
- Subroutines
-
- Branching Using Softkeys
-
- Error Testing and Recovery
-
- The ON HALT Statement
-
- The KEYBD function
-
- Structured Programming
-
Eloquence Language Manual - 19 DEC 2002