Hardware Reference
In-Depth Information
A succession of If ... EndIf statements may be used where a number of
outcomes need to be tested for. As an example, the following pseudo code
describes part of a process employed in a flow soldering plant:
If temperature < 230°C
Stop conveyor
Turn on heater
EndIf
If temperature > 230°C and temperature < 270°C
Start conveyor
Turn on heater
EndIf
If temperature > 270°C
Display warning message
Stop conveyor
Turn off heater
EndIf
Figure 4.7(b) shows a control structure which may be adopted where two
outcomes are required. The pseudo code equivalent of this is known as If ...
Else ... EndIf . A typical example of the use of this control structure is found
in the following pseudo code:
If light level low
Lights on
Else
Lights off
EndIf
A further control structure provides for multiple branching (rather than binary
branching, as in the case of If ... Else ... EndIf ). This structure is illus-
trated in the flowchart of Figure 4.7(c) and a typical application might be in the
selection of a main menu option, as described by the following representative
pseudo code:
Select Case
1, Input new data
2, Get old data
3, Sort data
4, Print data
5, Exit
Else warn user
EndSelect
This (apparently complex) pseudo code can quite easily be implemented in
both BASIC and C. A typical BASIC routine to satisfy the pseudo code would
take the form:
SELECT CASE R$
CASE "1"
CALL NewData
CASE "2"
CALL OldData
Search WWH ::




Custom Search