BASIC and many input options…

Earlier this year, Jason Pittman shared a BASIC program with me that drew representations of all the letters of the alphabet. It was a cute program, and did some fancy drawing.

To select a letter, there was this block of code:

130 PMODE3,1:A$=INKEY$
140 IFA$="A"THEN410
150 IFA$="B"THEN510
160 IFA$="C"THEN590
170 IFA$="D"THEN680
180 IFA$="E"THEN750
190 IFA$="F"THEN820
200 IFA$="G"THEN900
210 IFA$="H"THEN1020
220 IFA$="I"THEN1100
230 IFA$="J"THEN1130
240 IFA$="K"THEN1220
250 IFA$="L"THEN1340
260 IFA$="M"THEN1410
270 IFA$="N"THEN1490
280 IFA$="O"THEN1560
290 IFA$="P"THEN1680
300 IFA$="Q"THEN1780
310 IFA$="R"THEN1890
320 IFA$="S"THEN2020
330 IFA$="T"THEN2100
340 IFA$="U"THEN2190
350 IFA$="V"THEN2250
360 IFA$="W"THEN2360
370 IFA$="X"THEN2440
380 IFA$="Y"THEN2490
390 IFA$="Z"THEN2550
400 GOTO130

I thought it might be fun to ask you — in the comments — to tell me how YOU would have done this. I can think of one way, that uses an Extended BASIC keyword, and another way, that would work on Color BASIC.

For a series of options that are sequential (like “A to Z”) there are certainly some options.

As a part two … what if they were not sequential? What if it was for a menu that had options like “A, B, C, D, Q, Z” or whatever? That let me think of a third way to do it to work in Color BASIC.

Comment away!

4 thoughts on “BASIC and many input options…

  1. Jerry Stratton

    In the process of typing in programs from Rainbow, I’ve seen a handful of ways of dealing with this. One of the more compact was Steve Kincade’s Blackjak from April 1984.

    220 DIMO$(26)
    355 REM ALPHABET
    360 DATA U4E4F4L8R8D4BR4,U8R6F2G2NL6F2G2NL6BR6,U8R8L8D8R8BR4,U8R7FD6GL7R7BR5,U8R8L8D4R6L6D4R8BR4,U8R8L8D4R6L6D4BR12,U8R8D2U2L8D8R8U4L4R4D4BR4,U8D4R8U4D8BR4,R4U8NL4NR4D8R4BR4,U2D2R8NU8BR4,U8D4R4E4G4F4BR4,NU8R6BR6,U8F4E4D8BR4,U8F8NU8BR4
    370 DATA U8R8D8L8R8BR4,U8R8D4L8D4BR12,U8R8D8L8R6H2F4H2BR6,U8R8D4L8R4F4BR4,R8U4L8U4R8BD8BR4,BR4U8L4R8BD8BR4,NU8R8NU8BR4,BR4H4NU4F4E4U4BD8BR4,NU8E4F4NU8BR4,E8G4H4F8BR4,BR4U4NH4E4BD8BR4,E8L8BD8R8BR4
    400 RESTORE:FORT=1TO26:READO$(T):NEXTT
    500 R$ = “HELLO WORLD”
    510 PMODE 3,1:PCLS 1:SCREEN 1,1:COLOR 0,1
    520 GOSUB 650
    599 GOTO 599
    650 L=LEN(R$):FORTY=1TO L:M=ASC(MID$(R$,TY,1))-64:IF M=-32THEN DRAW”BR10″:NEXTTY:RETURN ELSE DRAWO$(M):NEXTTY:RETURN

    Reply
  2. William Astle

    Since it’s drawing PMODE graphics, relying on Extended Basic would be fine so a set of DRAW strings in an array is probably the most obvious thing, as already shown by Jerry.

    If I needed to do something more complex that needed to run arbitrary code, I’d probably use some form of ON INSTR(….) GOTO (or GOSUB) as a general case. I might alternatively use ASC(…) as the ON expression depending on the exact circumstances.

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.