Remember QBASIC, the Microsoft BASIC interpreter bundled with DOS back before Win95? I’ve still got it on my WinXP machine, having copied it over from previous computers. It only takes up about 300K, occasionally comes in useful, and lets me keep some old stuff that I wrote before I started university.
I’d like to share two of my old QBASIC programs now: a short one and a long one.
Here’s the short one. Red Dwarf fans will remember the incident where Rimmer was so nervous about his astronavigation exam that his subconscious mind took over and he wrote “I am a fish” all over the examination paper. Well, this is the main loop from a program that causes “I am a fish” to be written over and over again no matter what the user types.
You can pretty it up by inserting your favourite termination condition, and by printing the examination question at the top of the screen. Adapting it to your favourite programming language is left as an exercise for the reader.
DO FOR letter = 1 TO 12 written = 0 DO UNTIL written user$ = INKEY$ IF user$ "" THEN written = 1 LOOP PRINT MID$("I am a fish ", letter, 1); NEXT letter LOOP
Now for the long one. It’s my attempt at working out some of the algorithms for a platform game when I was eighteen, before I started studying programming formally at university. You can find the code on my website. Please read the introductory paragraphs on that page before trying to test it, because otherwise it won’t work properly.
I disagree, incidentally, with people who say that learning BASIC inevitably harms programming style. That depends on whether the programmer is any good. Programming in BASIC and programming in a real language are two different things, and there’s no reason why techniques and paradigms learned in one should be difficult to dispense with in the other.