This program creates an animated nameplate display, prompting the user to enter their name (truncated to 15 characters) and then rendering it inside a decorative border built from block graphics. The top and bottom borders animate outward from the centre using a randomly selected block-graphic character drawn from the string defined in line 130, creating a filling or scrolling effect. The border characters include various ZX Spectrum block graphic combinations such as solid blocks, quarter blocks, and checkerboard patterns. The animation loops indefinitely by jumping back to line 135 to pick a new random character each cycle.
Program Analysis
Program Structure
The program divides into three clear phases: input and validation, static border drawing, and an infinite animation loop.
- Lines 20–60: Initialise
C$, prompt for a name, enforce a maximum length of 15 characters via string slicing, and reject empty input with aGOTO 40retry loop. - Lines 80–130: Draw a static rectangular border. Line 80 prints a solid top row and a bottom row of double-quarter blocks using block-graphic escape sequences. Lines 90–110 draw the left and right side pillars with a
FOR/NEXTloop. Line 120 centres the user’s name at row 2, column 11. - Lines 135–9995: The animation loop. A random character is selected from
R$and then printed symmetrically outward from the centre of the top and bottom border rows, one column step per iteration of the innerFOR Xloop, before jumping back to pick a new character.
Border Construction
Line 80 uses PRINT AT with long strings of block-graphic pairs to fill the top row (solid ▀ blocks) and the bottom row (▄ blocks). The side borders at columns 0 and 31 are drawn with a separate loop in lines 90–110, printing a single block-graphic character on each row 1–4. This approach separates the corner/edge logic from the fill logic cleanly.
Animation Technique
The animation is driven by lines 135–9995. Line 135 picks a random byte offset into R$ using INT (RND*LEN R$)+1, and line 140 extracts a single character. The inner loop at lines 150–9990 then prints that character symmetrically: at column 16-X and 15+X on both the top row (row 0) and bottom row (row 4), expanding outward from the centre with each increment of X. After a full sweep across 15 positions, control returns to line 135 for a new random character.
Character Palette in R$
The string R$ at line 130 encodes a palette of block-graphic characters used for the animation. Each two-character escape represents one displayable block graphic:
| Escape | Glyph |
|---|---|
\@@ | █ (full block) |
\~~ | ▒ (checkerboard) |
\,, | (inverse comma graphic) |
\!! | ▒ (inverse) |
\;; | (inverse semicolon graphic) |
\' | ▘ |
\.. | ▄ |
\'' | ▀ |
\ ' | ▝ |
\ . | ▗ |
\ : | ▐ |
\'= | ▜ |
\:. | ▙ |
Because R$ is indexed one byte at a time, each two-byte escape is actually two separate selectable characters, meaning some selections will land mid-escape and produce an unintended character. This is a minor anomaly but causes no crash — it simply adds variety to the animation.
Input Validation
Line 50 truncates any name longer than 15 characters using the substring form N$(1 TO 15). Line 60 rejects a zero-length name by looping back to the INPUT statement. There is no upper-bound guard on very short names, but the PRINT AT 2,11 placement means names up to 15 characters fit within columns 11–25, well inside the 32-column display.
Notable Idioms
- The use of high line numbers (9990, 9995) for the
NEXTandGOTOstatements is an aesthetic choice that visually separates the animation core from setup code without affecting execution. LET C$=" "at line 20 pre-declares the variable before it is used in the animation loop, avoiding a potential uninitialized-variable edge case on the first pass before line 140 assigns it.- The
SAVE "1013%4"at line 9998 followed byRUNat 9999 are standard tape-save and auto-restart lines appended after program logic.
Content
Source Code
20 LET C$=" "
30 PRINT "ENTER YOUR NAME"
40 INPUT N$
50 IF LEN N$>15 THEN LET N$=N$(1 TO 15)
60 IF LEN N$=0 THEN GOTO 40
80 PRINT AT 0,0;"% \''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''% ";AT 4,0;"% \..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..% "
90 FOR G=1 TO 4
100 PRINT AT G,0;"% ";AT G,31;"% "
110 NEXT G
120 PRINT AT 2,11;N$
130 LET R$="\@@\~~\,,\!!\;;\@@\' \..\''\..\''\..\..\'' \ ' \.. \ : \..\'' \ :"
135 LET H=INT (RND*LEN R$)+1
140 LET C$=R$(H)
150 FOR X=1 TO 15
160 PRINT AT 0,16-X;C$;AT 0,15+X;C$
170 PRINT AT 4,16-X;C$;AT 4,15+X;C$
\n9990 NEXT X
\n9995 GOTO 135
\n9998 SAVE "1013%4"
\n9999 RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
