How Long Is a Word?
Use LEN to count letters and draw blue tiles — one per character, centred on screen.
The game screen shows a word, but it just sits there as plain text. Word Scramble needs something more — a row of blue tiles, one per letter, centred on screen. To draw the right number of tiles, the program needs to know how long the word is.
LEN — Counting Characters
10 LET w$="cat"
20 PRINT w$;" has ";LEN w$;" letters"
30 LET w$="planet"
40 PRINT w$;" has ";LEN w$;" letters"
50 LET w$="adventure"
60 PRINT w$;" has ";LEN w$;" letters"
LEN w$ returns the number of characters in a string. “cat” has 3, “planet” has 6, “adventure” has 9. Spaces count too — LEN "hi there" is 8. An empty string "" has a length of 0.
LEN isn’t just a fact about a string — it’s a tool. If you know how long a word is, you can draw the right number of tiles, centre them on screen, and loop through each character position.
Drawing Tiles
5 BORDER 0: PAPER 0: INK 7: CLS
10 FOR i=0 TO 31
12 PRINT AT 0,i; PAPER 2;" "
14 NEXT i
16 PRINT AT 0,8; PAPER 2; INK 7; BRIGHT 1;" WORD SCRAMBLE "
20 PRINT AT 4,10; INK 5;"Unscramble:"
30 LET w$="cat"
32 LET c=(32-LEN w$*2)/2
34 FOR i=1 TO LEN w$
36 PRINT AT 8,c+i*2-2; PAPER 1;" "
38 PRINT AT 9,c+i*2-2; PAPER 1;" "
40 NEXT i

Three blue squares appear in the middle of the screen. Change w$ to “planet” and six tiles appear. Change it to “adventure” and nine tiles fill a wider space — always centred.
Here’s how the centring works:
- Each tile takes 2 columns: one for the letter, one gap
- A word of length
LneedsL * 2columns - The starting column is
(32 - L * 2) / 2 - Tile
isits at columnc + i * 2 - 2
The FOR loop on lines 34-40 draws two rows of blue (PAPER 1) spaces for each letter position. Two rows tall makes the tiles feel solid, not like thin underlines.
Try This
Longer words. Change w$ to “strawberry” (10 letters) or “hippopotamus” (12). Watch the tiles stretch across the screen. At what length do they run out of space?
Different colour. Replace PAPER 1 with PAPER 3 (magenta) or PAPER 4 (green). Pick the colour that looks best against the black background.
What You’ve Learnt
- LEN — returns the number of characters in a string
- LEN in a loop —
FOR i = 1 TO LEN w$runs once per character - Centring formula —
(32 - LEN w$ * 2) / 2finds the starting column - Coloured tiles —
PAPERinsidePRINT ATcreates coloured blocks