This program demonstrates a one-line horizontal text scrolling technique by continuously printing a 32-character window of a long string at screen row 10. It uses BASIC’s substring notation `A$(X TO X+31)` to extract successive 32-character slices and prints them at a fixed screen position using `PRINT AT`, creating the illusion of smooth scrolling. A `PAUSE 10` between frames controls the scroll speed. The program halts automatically when the window reaches the end of the string, detected by checking `(X+31)=Z` against the string’s length.
Program Analysis
Program Structure
The program is organized into a simple sequential loop with a setup phase, a display loop, and a termination condition:
- Line 5 — Sets display attributes: white ink, black paper, black border.
- Line 10 — Defines the scroll string
A$, a long message with deliberate padding of trailing spaces. - Line 20 — Initializes the window pointer
X=1and caches the string length inZ. - Lines 30–50 — Main scroll loop: print a 32-character window, advance the pointer, check for end condition, pause, then repeat.
- Line 9997 — Redundant
STOPguard (never reached in normal execution). - Line 9998 —
SAVEwith auto-run at line 1 (but execution begins at line 5, so the auto-run target is effectively a no-op start).
Scrolling Technique
The core of the effect is on line 30:
PRINT AT 10,0;A$(X TO X+31);" ";
This extracts a 32-character substring starting at position X and prints it at column 0 of row 10. Because the PRINT AT statement overwrites exactly those character cells and the trailing " " suppresses a newline scroll, the display updates in-place each iteration. Incrementing X by 1 on each pass shifts the visible window one character to the left, producing the scrolling illusion.
Termination Condition
Line 40 checks (X+31)=Z to detect when the right edge of the 32-character window has reached the last character of the string. At that point execution stops. Note this uses equality rather than >=, so it depends on the loop always advancing by exactly 1 — which it does. The large block of trailing spaces in A$ ensures the message fully scrolls off before the stop condition is triggered.
Key BASIC Idioms
LET Z=LEN A$cached at line 20 avoids recalculating string length on every iteration, a minor but sensible optimization.- The trailing semicolon on the
PRINTstatement suppresses the automatic newline and prevents the display from scrolling vertically. PAUSE 10(approximately 0.2 seconds at 50 Hz) throttles the scroll speed; removing or reducing it would make the scroll nearly unreadable.A$(X TO X+31)uses the standard slice notation to extract a fixed-width window from the string.
Potential Bugs and Anomalies
| Issue | Detail |
|---|---|
| Auto-run line mismatch | SAVE "SIDESCROLL" LINE 1 targets line 1, which does not exist; execution would begin at line 5 (the first actual line), so this is harmless in practice. |
| Off-by-one risk | If A$ length is not carefully chosen such that (X+31)=Z is ever exactly true, the loop would run past the end of the string and trigger a substring error. The generous trailing spaces in A$ guard against this in practice but the logic is fragile for arbitrary strings. |
| No wraparound | The scroll is one-shot only; there is no mechanism to loop the message continuously. |
Content
Source Code
5 INK 7: PAPER 0: BORDER 0
10 LET A$="THIS IS AN EXAMPLE PROGRAM TO SHOW HOW FAST THE TIMEX SINCLAIR 2068 CAN ACTUALLY SCROLL A STRING ACROSS THE SCREEN. IT IS SO FAST THAT YOUR BRAIN GETS MUDDLED UP UNTIL YOUR EYES BEGIN TO HURT. IF YOU LOOK AT THE PROGRAM TO DO THIS YOU WILL FIND THAT YOU CAN HAVE ANY STRING OF CHARACTERS IN A$ AS LONG AS THERE ARE MORE THAN 32!. HAPPY PROGRAMMING!!!!!!!!!!!! "
20 LET X=1: LET Z=LEN A$
30 PRINT AT 10,0;A$(X TO X+31);" ";
40 LET X=X+1: IF (X+31)=Z THEN STOP
45 PAUSE 10
50 GO TO 30
9997 STOP
9998 SAVE "SIDESCROLL" LINE 1
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
