!* Program Name : JUMP
!* Title : X The IMP Control Transfer Statements.
!* Version : II
!* Date : 24 August 1985
!* Description: Testing of the ->, %SWITCH and %LABEL Statements.
Begin
string(255) param { Used to get input from CLI}
Integer J
Integer K
Integer Error
Integer Up
Integer Down
Switch SW (100 : 355) { Non-zero base switch with lot of switches.
Label Alpha
Label Beta
Label Gamma
Label Delta
Label Out
Label Cont
owninteger failures=0
routine pass
printstring("Pass")
New Line
end
routine fail
printstring("FAIL")
New Line
failures = failures+1
end
! Code to find out where the output is to be sent
! -----------------------------------------------
! Where the output goes to depends on the parameter after the
! name used to run the program.
! Parameter | Result
! ------------|-------------
! No parameter | No output
! "s" | The screen
! "j" | "journal"
! anything else | file name entered
! NOTE THAT THIS CODE USES STRING COMPARISONS, WHICH MAY NOT HAVE BEEN
! TESTED YET. IF THE PROGRAM FAILS CHECK IT WAS NOT IN THIS PART.
param=cliparam
if param = "" then select output (2) c
else if param="s" or param="S" then select output (0) c
else if param="j" or param="J" then c
open output(2,"journal") and select output (2) c
else open output(2,param) and select output (2)
New Lines(2)
Print String ("Control Transfer Statements"); New Line
Print String ("==========================="); New Lines (3)
Print String ("Test the -> Statement and %Switch"); New Line
Print String ("---------------------------------"); New Line
Up = 0
Down = 0
-> Delta
Alpha: Up = Up + 1; -> Gamma
Beta: Down = Down + 1; -> Out
Gamma: Up = Up + 1; -> Beta
Delta: Down = Down + 1; -> Alpha
Out:
If Up = Down = 2 then pass else fail
! Forward and Backward simple jumps.
Up = 100
Error = 0
For J = 990, 10, 3540 cycle
-> SW (J // 10 + 1) { Introduces an integer expression in the switch
SW(140): Error = Error + 1 unless Up = 140
-> Cont
SW(255): Error = Error + 1 unless Up = 255
-> Cont
SW(105): Error = Error + 1 unless Up = 105
-> Cont
SW(304): Error = Error + 1 unless Up = 304
-> Cont
SW(182): Error = Error + 1 unless Up = 182
-> Cont
SW(354): Error = Error + 1 unless Up = 354
-> Cont
SW(111): Error = Error + 1 unless Up = 111
-> Cont
SW(193): Error = Error + 1 unless Up = 193
-> Cont
SW(121): Error = Error + 1 unless Up = 121
-> Cont
SW(201): Error = Error + 1 unless Up = 201
-> Cont
SW(296): Error = Error + 1 unless Up = 296
-> Cont
SW(160): Error = Error + 1 unless Up = 160
-> Cont
SW(122): Error = Error + 1 unless Up = 122
-> Cont
SW(101): Error = Error + 1 unless Up = 101
-> Cont
SW(202): Error = Error + 1 unless Up = 202
-> Cont
SW(301): Error = Error + 1 unless Up = 301
-> Cont
SW(355): Error = Error + 1 unless Up = 355
-> Cont
SW(200): Error = Error + 1 unless Up = 200
-> Cont
SW(324): Error = Error + 1 unless Up = 324
-> Cont
SW(*): -> Cont
SW(109): Error = Error + 1 unless Up = 109
-> Cont
SW(256): Error = Error + 1 unless Up = 256
-> Cont
SW(145): Error = Error + 1 unless Up = 145
-> Cont
SW(165): Error = Error + 1 unless Up = 165
Cont: Up = Up + 1
Repeat
If Error = 0 and Up = 356 then pass else fail
! %Switch operation.
select output(0)
write(failures,1); printstring(" failure(s)"); newline
End of Program