The second Thing a Week comes a bit late, but better late than never I suppose. Packing for the upcoming move, KansasFest prep and podcast editing have taken a big bite out of my time, and it’s things like this blog that suffer for it.
Anyway, here’s a quick and easy program. It doesn’t really do anything, but again that’s not the point. At the four corners of a 40-column text screen, the Apple II displays a repeating counter, going from 1 to 10.
There is no official end to the program – it just loops over and over which, I realize is a bad practice (Mr. Clausen from 4th period Computer Programming class would be furious) but I just wanted to play with a simple loop and some easy text display.
Ideally, I’d like it to clear the counters after they reach 10 so that the extraneous ‘0’ disappears before they start over, without having to clear the screen with a HOME command – maybe I’ll tinker with that next time. I think I want to build on this one.
]LIST
5 REM THING A WEEK 2 – 6502LANE.NET
10 HOME : CLEAR
15 I = 0
20 FOR I = 1 TO 10
30 VTAB 1: HTAB 1: PRINT I
40 VTAB 1: HTAB 23: PRINT I
50 VTAB 23: HTAB 1: PRINT I
60 VTAB 23: HTAB 23: PRINT I
70 NEXT I
80 GOTO 10
]
Or, just run the counter from 0 to 9… (corrected to go the actual corners… except for the absolute lower-right, exercise left to the reader…)
5 REM THING A WEEK 2 – 6502LANE.NET
10 HOME : CLEAR
20 FOR I = 0 TO 9
30 VTAB 1: HTAB 1: PRINT I
40 VTAB 1: HTAB 40: PRINT I
50 VTAB 23: HTAB 1: PRINT I
60 VTAB 23: HTAB 40: PRINT I;
70 NEXT I
80 GOTO 20
Mr. Clausen was looking over my shoulder the whole time.
Here’s a version that illustrates two approaches to erasing leftover digits–one left-justifying and the other right-justifying. (I pulled the numbers one in from the edge, just to make it neat without fussing with putting a character in the lower right corner.) I also removed some unnecessary commands, and added a keystroke check (just because i hate the mess of the break message ☺).
10 HOME
15 W = PEEK(33)
20 FOR I = 1 TO 10
30 VTAB 2 : HTAB 2 : PRINT I " ";
40 HTAB W-2 : PRINT RIGHT$(" "+STR$(I),2);
50 VTAB 23 : HTAB 2 : PRINT I " ";
60 HTAB W-2 : PRINT RIGHT$(" "+STR$(I),2);
70 NEXT I
80 ON PEEK(49152)<128 GOTO 20 : POKE 49168,0