Number to Word

Developer(s): John Bell
Date: 1985
Type: Program
Platform(s): TS 2068
Tags: Home

Turns a seven-digit telephone number into every combination of letters it can spell on a telephone keypad. You type the number, confirm it, and the program prints all 37 = 2,187 seven-character combinations across the screen, four to a line. It scrolls without stopping; holding down a key pauses the listing. The digits 0 and 1, which have no letters, print as themselves.

“Number to Word” is by John Bell and was published as a TS 2068 type-in in T-S Horizons #14 (May/June 1985). The REM calls this the “2068 VERSION”. This copy comes from a Larken disk of magazine type-ins. The same letter tables and nested-loop routine also appear in the Word Plays program in this archive, as its phone-number option.

Program Analysis

How It Works

  • Lines 30–80: A$ is a 3×10 table. Row n holds the nth letter for each key 0–9 (“01ADGJMPTW”, “01BEHKNRUX”, “01CFILOSVY”), so Q and Z are left out, as on the keypads of the time.
  • Lines 100–150: input and confirmation of the number.
  • Lines 180–380: seven nested FOR loops, one per digit, each choosing row 1, 2 or 3; the choices are kept in array N.
  • Lines 260–300: build the word in C$ from A$(N(H),VAL B$(H)+1) and print it.

Notable Techniques

  • POKE 23692,255 before each print keeps the scroll counter from stopping at “scroll?”.
  • IF INKEY$<>"" THEN PAUSE 660 gives a simple hold-to-pause.
  • POKE 23658,8 turns on caps lock for the input.

Potential Issues

  • Only numbers longer than seven characters are rejected. A shorter entry, or one with a non-digit, appears to stop the program with an error once the conversion starts.
  • The length check jumps back to line 50, which re-dimensions N; this is harmless.

This program came from a Larken disk and was converted to run from tape: the LKDOS save and load lines and the LOGICALL load were removed, and it is saved without variables. It was tested in ZEsarUX with the number 555-0123.

Related Articles

Convert a 7 digit phone number to all possible letter/number combinations.

Related Content

Image Gallery

Source Code

    1 REM NUMBER TO WORD                   2068 VERSION
    2 REM ********************
   10 REM SET UP
   20 POKE 23658,8
   30 DIM A$(3,10)
   40 DIM C$(7)
   50 DIM N(7)
   60 LET A$(1,1 TO 10)="01ADGJMPTW"
   70 LET A$(2,1 TO 10)="01BEHKNRUX"
   80 LET A$(3,1 TO 10)="01CFILOSVY"
   90 REM DATA ENTRY
  100 INPUT "7 DIGIT NUMBER? ";B$
  110 IF LEN B$>7 THEN GO TO 50
  120 PRINT AT 21,0;B$
  130 INPUT "IS THE NUMBER CORRECT? ";D$
  140 IF D$="y" OR D$="Y" THEN GO TO 160
  150 GO TO 100
  160 CLS 
  170 REM PROCESSING
  180 FOR A=1 TO 3: LET N(1)=A
  190 FOR B=1 TO 3: LET N(2)=B
  200 FOR C=1 TO 3: LET N(3)=C
  210 FOR D=1 TO 3: LET N(4)=D
  220 FOR E=1 TO 3: LET N(5)=E
  230 FOR F=1 TO 3: LET N(6)=F
  240 FOR G=1 TO 3: LET N(7)=G
  250 REM CONVERSION
  260 FOR H=1 TO 7
  270 LET C$(H)=A$(N(H),VAL B$(H)+1)
  280 NEXT H
  290 POKE 23692,255
  300 PRINT C$;" ";
  310 IF INKEY$<>"" THEN PAUSE 660
  320 REM CONTINUE PROCESSING
  330 NEXT G
  335 NEXT F
  340 NEXT E
  350 NEXT D
  360 NEXT C
  370 NEXT B
  380 NEXT A
  400 PRINT "PROGRAM COMPLETE"
 8999 STOP 
 9000 SAVE "FONEWORDS": STOP 
 9010 VERIFY "FONEWORDS"
 9992 SAVE "FONEWO.B1" LINE 1
 9998 REM  was LKDOS-only

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.