What is wrong with this program?
Here is an interesting puzzle for those of you who like this sort of thing. Run both programs and press any key (except BREAK) five times. You will get five different numbers. Although the only difference is the location of the PRINT output, the two lists you’ll get are not the same! Where’s the bug?
(note) the line 1 REM is identical in both programs – follow this procedure to ENTER the machine code.
1. ENTER 1 REM 1234
2. ENTER POKE 16514,38
3. ENTER POKE 16515,134
4. ENTER POKE 16515,60
5. ENTER POKE 16516,129
Now look back and see what happened to line #1. It is not 1 REM 1234 anymore. It is 1 REM A,(shifted graphic Y), W, (Shifted Graphic Q)- you have just entered a MC routine.!!
Now back to our problem:
PROGRAM # ONE PROGRAM # TWO
1 REM (w/4 characters) 1 REM (W/4 characters)
10 FOR J = 16514 TO 16518 10 FOR J = 16514 TO 16518
20 PRINT AT 10,10; PEEK J 20 PRINT PEEK J
30 PAUSE 40000 30 PAUSE 40000
40 NEXT J 40 NEXT J
THE KEYBOARD
When you first look at the keyboard you probably feel it is not very sensitive. If you still feel that way – or a “kibitzer” is being critical – try the following little routine:
10 PRINT " TYPE ANY LETTER - YOU DO NOT NEED ENTER"
20 IF INKEY$ = "" THEN GOTO 20
30 PRINT INKEY$
40 GOTO 20
HOW’S THAT FOR SENSITIVE!!!
HINTS FOR WHAT’S WRONG WITH THIS PROBLEM-above ^
1) One of the lists contains a number that’s impossible as a result of a PEEK operation.
IF (you’re not sure what PEEK means) THEN don’t worry
IF (you’re not sure what PEEK means) THEN GOTO Hint #2
IF (you do know what what PEEK means) THEN STAY WITH HINT #1 awhile!
2) Try this variation on the program:
1 REM (SAME 4 CHARACTERS)
10 FOR J = 16514 TO 16518
20 PRINT AT 10,10; PEEK J
30 PAUSE 40000
35 PRINT AT 10,10; " " ( 3 BLANK SPACES )
40 NEXT J
ANSWERS TO PREVIOUS PROBLEMS OR AT LEAST SOME HINTS!
AS IS – RUN THIS PROGRAM NOW CHANGE IT TO THIS PROGRAM
10 LET A$ = "A$" 10 LET B$ ="A$"
15 DIM A$(2,2) 15 DIM A$(2,2)
20 LET A$(1) =A$ 20 LET A$(1) = B$
25 LET A$(2) ="22" 25 LET A$(2) ="22"
30 PRINT A$(1),A$(2) 30 PRINT A$(1),A$(2)
RESULT ON RUNNING: RESULT ON RUNNING ERROR CODE 3/20 A$ 22
Now try in immediate mode:
PRINT A$ (Result should be ERROR CODE 3/0)
Can you explain it?
This is one of those condensations that involve the proper use of the “connectors (see chapter 7 in the TIMEX manual) -THE PROGRAM AS LISTED IN THE NEWSLETTER:
10 INPUT A
20 INPUT B HINT - THINK OF LINE 30 AS SAYING
30 LET X = (A=B)*2 IF A = B THEN PRINT TRUE
40 PRINT X
50 GOTO 10
IN THIS CASE “2” IS TRUE, 0 IS FALSE
THE ONLY RESULTS OF RUNNING THIS PROGRAM SHOULD BE “2” AND “0”.
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.