The modified program:
! MExample Program 8-3
! Use an array to display the day name
! corresponding to a number.
! Print in a loop
! Data 1,2,3,4,5,6,7,0
DIM Day$(1 to 7)
FOR I = 1 to 7
READ Day$(I)
NEXT I
DATA Sunday, Monday, Tuesday, Wednesday
DATA Thursday, Friday, Saturday
DATA 1,2,3,4,5,6,7,0
PRINT "Enter a number between 1 and 7"
PRINT "and the corresponding day of the week"
PRINT "is displayed. Enter zero to stop."
LET Number = 666 ! so the do-loop will run
!INPUT prompt "Day number? ": Number
DO until Number = 0
READ Number
SELECT CASE Number
CASE 1
SET COLOR "red"
CASE 2,3,4,5,6
SET COLOR "blue"
CASE 7
SET COLOR "green"
CASE else
SET COLOR "black"
END SELECT
IF Number = 0 then
PAUSE 5
END IF
PRINT "Day number"; Number; "is "; Day$(Number)
!INPUT prompt "Day number? ": Number
LOOP
END
With output:
Enter a number between 1 and 7
and the corresponding day of the week
is displayed. Enter zero to stop.
Day number 1 is Sunday
Day number 2 is Monday
Day number 3 is Tuesday
Day number 4 is Wednesday
Day number 5 is Thursday
Day number 6 is Friday
Day number 7 is Saturday
Day number 0 is ... produces a run time error "subscript out
of bounds" from Day$(0)