C64IntroBASIC2Part 2 of “An Introduction to BASIC”

This post is part 3 in the series, but is about the book “An Introduction to BASIC – Part 2”. I won’t bother to write a separate article to de debunk any posts by TMR on the blog , but I will say that as a former Amstrad CPC user who never owned a Sinclair Spectrum, I was confused by this when I wrote that Spectrum users could select colours with the command PEN n. On the Amstrad CPC the command INK n1,n2 assigned the actual colour n2 to the logical colour n1. The Amstrad used a palette of 16, 4, or 2 colours from a total choice of 27 colours. I also need to point out that back in 1984 I was paying great attention to each unit in “An Introduction to BASIC”, because I was keen to learn programming in general, but especially how to program music on my Commodore 64. I realised that any or all of the C64 BASIC commands may also be involved with playing music. The video posted by TMR shows Commodore BASIC V2 programs playing 3 note polyphonic music, but these programs contain more POKE commands than I care to count!

The whole course “An Introduction to BASIC” seems to be written by Andrew Colin, based in Glasgow. As the first book was written in 1982 when the Commodore 64 came out, as well as him mentioning the “VIC Super Expander”, I assume he learnt how to program on the Commodore VIC-20 or even the Commodore PET. Only a few of the 26 units making up this course are anything to do with C64 specific features, such as the screen memory, colour memory, the SID chip, and the VIC-II chip with its sprites.

Part 2 of the course “An Introduction to BASIC” is made up of 11 units, numbered 16 to 26, plus an Appendix. It takes until Unit 25 before the course gets on to programming a simple text only, adventure game, while the final Unit 26 is about sprites. Playing music isn’t dealt with until the Appendix! There are no programs which make use of hires graphics at all!!

Unit 16 is about using DATA, READ, and RESTORE to calculate paying wages in cash according to the notes and coins in circulation in Britain at the time from half a penny up to £20, then asks the user to modify the program so that it works for the notes and coins in circulation in the USA, where it claims the highest denomination was $50 instead of using any higher denominations, not even $100. It advises readers that DATA statements must be separated by a comma so that no piece of data can contain a comma, unless it’s enclosed in quotes. It goes on to deal with making a calendar and formatting dates. After this follows one of the most useful programs in the book, showing readers how to write a quiz, which is accompanied by a flowchart showing how the program works. The DATA statements could be replaced by any questions and answers. I used this to write my own quiz programs to memorise vocabulary from any language I chose, but of course I couldn’t have any music or graphics to accompany any quizzes I programmed on the Commodore 64.

Unit 17 has the use of colons and IF…THEN loops to deal with selling beer and whisky. There’s also an explanation of the logic operators AND, OR, and NOT. These logic operators even had to be used to set the bits of registers in the VIC-II graphics and SID sound chips, but although they’re used for this purpose in the course, there’s no explanation of what’s happening. One possible use of them which is shown is that all potential employees of a security company must be at least 18 years old and 64 inches tall, which is accompanied by a flowchart, but height was never measured just in inches, which were obsolete before this book was written in any case, so this was part of a massive conspiracy to persuade people not to use metric measurements. This is why people now talk about tablets and ereaders with the screens measured in INCHES! The syntax of using OR in BASIC is explained, compared with its use in normal English. Another example is shown of combining AND with OR to check whether applicants are old enough to to get a licence to ride a motorcycle, a car, or a bus. After this, the operator NOT is demonstrated. Commodore BASIC V2 requires these operators to be used a lot more than numerous other versions of BASIC, due to the lack of the command ELSE, although the Sinclair Spectrum lacks the command ELSE as well. This kind of programming was demonstrated showing how it could be applied to games by Fred Harris in the series “Me and My Micro”, on the Sinclair Spectrum, as well as the Acorn Electron in BBC BASIC. He said something like getting through a maze was a bit like buying fish and chips. You couldn’t buy any unless you were in the right place AND the fish and chip shop was open. Of course, this program also used the amazing PRINT AT y,x command on the Sinclair Spectrum and the equally amazing PRINT TAB (x,y) command in BBC BASIC on the Acorn Electron.

Unit 18 introduces subroutines and describes how they work. It explains that you need to have subroutines for anything more than fairly short programs. Of course, Commodore BASIC V2 lacks the DEF PROC, END PROC, and PROC commands for procedures found in the vastly superior BBC BASIC and similar commands in the excellent SuperBASIC on the ill fated Sinclair QL. Similar commands exist in Simons’ BASIC. Subroutines are described as better than GOTO commands, because the program remembers what line number it was at when a GOSUB command was given and can return to the next instruction. It mentions that the languages PASCAL and ADA have different, more complicated ways of doing this, but doesn’t say anything about procedures. After this, it shows a simple routine to move a “monster”, made up of nothing more than a space character coloured red, horizontally across the screen. Of course, moving it up and down the screen would be a lot more complicated, due to the lack of any PRINT TAB command which can specify a vertical parameter, or a LOCATE x,y command. After this, the unit ends by telling the reader to load a program which draws a crude picture of a house, made up of graphics characters.

Unit 19 tells the reader more about developing and refining subroutines for various uses and how to plan them out. After this follows a subroutine just to make a pip sound. This is only necessary as the subroutine contains a total of seven POKE commands. This is obviously because Commodore BASIC V2 is crap! After this, the reader is told to load a subroutine which enables characters to be displayed at four times their normal size and to try to write a program which uses this subroutine.

Unit 20 explains arrays and their uses, such as remembering a list of pupils in a class at school. It introduces the use of a flag, such as ZZZZ to indicate that a list of surnames has ended. A problem is set, asking the reader to write a program that uses a list of DATA statements containing surnames and phone numbers.

That’s all for now about “An Introduction to BASIC – Part 2”, because my article about it is so long. This means you can look forward to the next installment in this exciting series very soon!

Posted September 22, 2014 by C64hater in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: