Today special topic! The Basic language programming course begins! Today’s video is about creating a very simple program (the video is in Italian, but you can activate English subtitles).
Let’s see how to type the program, how to view the instructions list, how to modify it, and then start it and even stop it. We begin to learn how the computer thinks and we discover first commands.
The lines of instructions that we analyze today are: REM, PRINT, INPUT and GOTO. We also use the special keys: RUN / STOP, SHIFT + CLR-HOME and SHIFT + INST-DEL. The commands we analyze are: RUN, CONT and LIST.
In the next videos, we will also see how to save and load files, how to transfer them to the PC and vice versa and also how to create programs on the PC, using the notepad, and then transfer them to the Commodore and run them.
Here is the program to type!
And here is the example program of the first lesson of the Basic language programming course. At the bottom of this page, you can already find it in TXT format (to view it on the screen), and in PRG format, to start it on the Commodore 64.
10 REM MY FIRST BASIC PROGRAM 20 REM WWW.VALOROSO.IT 30 INPUT "WHAT IS YOUR NAME";A$ 40 PRINT "HELLO " A$ "! "; 50 GOTO 40: REM GO TO LINE 40
Basic language programming course, for which computers?
The simple program that we create in the tutorial can be run on many different Commodore: on the Commodore 16, on the Commodore Vic20, on the C64, on the C128, but also on the Commodore PET. It can also be run on emulators (for example the emulators for Windows VICE and CCS64) and you can also run it on the old GWBASIC that was in the DOS of PCs. You can also run it on the QB64 QuickBasic, that can compile the program in Windows, Linux and MacOS.
If you are using the Commodore PET, remember to type the program in all lowercase.
If the topic interests you, I suggest you subscribe to my YouTube channel and activate the notification bell, in this way you will be notified when I publish the other episodes of the course.
Sequence of instructions
Let’s start the Basic programming course with a question: do you know how the instructions are executed in Basic?
The computer executes the instructions in sequence, from the lower line number to the upper one, unless there are instructions such as GOTO, GOSUB, functions or cycles, which can jump from one point to another in the program.
Each line of the program begins with a number. It doesn’t matter what number it is, the important thing is that each row has a different number.
If we write a line with the same number several times, only the most recent one remains in memory. In addition, I recommend leaving some empty numbers between the various lines, also to be able to insert other features in the future
To confirm and store the program line, after typing it, press RETURN (or ENTER if you are using a PC emulator, such as VICE or CCS64). Remember that the instructions must be entered precisely and correctly, with all spaces and punctuation marks. Otherwise the program may not work! If we want to type more instructions on the same line, in Basic these are divided with a colon “:”. In line 50 of the program, there are two statements: GOTO and REM.
Basic language programming course: REM instruction
The first instruction we see in the tutorial, REM, indicates a comment that we want to include in the program: it is useless in execution, but it is useful to remind us, in the future, what the program or part of it is for.
It is good to put a lot of comments in the programs, to remind us not so much what the various instructions are for, for this there are the manuals, but more to remind us of the operating logic of the software we have created. In the second comment line, I suggest this website, where I publish my videos and articles!
INPUT? What is it for in Basic?
The third line of the program, the one indicated with 30, contains an instruction, INPUT, which indicates a data input. The computer asks us what we have indicated in the quotation marks, in this case “What is your name”. Question mark is automatically added by the Basic. Our response, which we type on the keyboard, is saved in a variable, which is a data container. In this case, I added a dollar $ after the variable name A$, to specify that it is a string, that is, I expect a sequence of characters and not, for example, a number to count on.
Going deeper into the question of variables, we must consider that the Commodore Basic considers only the first two letters of the variable name, therefore, for example, the variables ABC$, AB$, but also ABD$ represent the same container.
PRINT instruction
The PRINT instruction, present in the fourth line of the example program for the Basic language programming course, is used to write on the screen. In our example, the computer writes what is indicated in the quotation marks, but also the variable, which we typed earlier, and the exclamation point. The message “HELLO” is concatenated with the name contained in the variable A$ as well as the exclamation point. The semicolon at the end of the line is used to indicate to the Basic not to wrap, with the cursor, after having finished writing on the monitor.
PRINT statement can also write to other destinations, such as a file or printer. This, however, we will see in other episodes of the course.
Basic language programming course: GOTO instruction
The GOTO instruction is used to move the program execution sequence and is therefore useful for jumping to another line (in the case of the example of the Basic language programming course, line 40).
Run a program in Basic
After typing the entire program of the programming tutorial in Basic, we can start it by typing RUN and pressing RETURN on the keyboard (or ENTER on the CCS64 or VICE emulator for PC).
We see it on various computers: on the Commodore 64, on the C16, on the Commodore Vic20, on the emulator for the Commodore PET, on the C128. We also see this on the GWBASIC for DOS of an IBM computer. It is always the same program and works on all devices.
Manage the execution of the program
To stop program execution, press the RUN / STOP key on the Commodore keyboard.
On emulators, the RUN / STOP key is replaced by ESC. So, both on VICE and on CCS64, to stop the execution of the program, we must press ESC.
On the Commodore PET VICE emulator, you must press CTRL to stop the program. On the Commodore Plus4 emulator, the key is END.
It is possible to restart the program from where it left off by typing the CONT command. If we had typed RUN instead of CONT, the program would have restarted from the first line.
Display the instruction list of the program, LIST command
After typing the tutorial program, when it is not running, you can recall and view the typed listing.
First, to clean the monitor you need to press the SHIFT and CLR-HOME keys simultaneously. On Windows emulators, you need to press SHIFT + HOME (or SHIFT + START). The monitor is cleaned, but the program is not cleared. To view the listing of the program we typed earlier, we type the LIST command and press RETURN. The example program of the Basic language programming course is short and fits all in one screen.
In case the program is much longer, it is possible to display only a certain range of lines, for example:
- LIST -20 displays up to line 20;
- LIST 30 displays only line 30;
- LIST 30- shows the program from line 30 onwards;
- LIST 20-30 displays the listing from lines 20 to 30, included.
Change program lines to Basic
It is possible to modify the program lines, simply by moving the cursor over it, modifying the relevant line. After making the changes, you must confirm the insertion of the line by pressing RETURN.
It may be necessary to insert some blank spaces in the line, for example when the edited text is longer than the previous one. In this case, you can insert the missing spaces by pressing SHIFT + INST-DEL on the Commodore keyboard. On emulators installed on Windows, the keys can be SHIFT + DEL (backspace) or, SHIFT + INS.
Download the Basic example program of the step by step tutorial
And here is the listing of the Basic program of the first video of the Commodore’s Basic language programming course.
The program is available in two formats:
- COURSE-BASIC-1. TXT, in text format (comments and texts are in Italian), to analyze it on a PC or to transcribe it on the various Commodore, on the DOS GwBasic or on the QB64;
- COURSE-BASIC-1. ZIP, ZIP compressed folder to unpack (comments and texts are in Italian). It includes the program in PRG format, loadable and bootable from Commodore 64 and a virtual disk D64 containing the program loadable from C16, Vic20, C64 and C128, as well as emulators (CCS64, VICE or others).
The topics of the course are still a lot!
Credits: in the video tutorial, SID music is Noisy Pillars by Jeroen Tel.
This course is super amazing!
Thank you for the interesting course.
By the way, how can we communicate?
Hello, thank you. You can contact me here: https://www.valoroso.it/contatta-amedeo-valoroso/
I couldn’t refrain from commenting. Well written!
Thank you!
Informative article, exactly what I needed.
Thank you!
Hello! I’ve been reading your site for a while now and finally got the bravery to go ahead and give you a shout out from Porter Tx! Just wanted to mention keep up the fantastic job!
Thank you!
Great post. Keep writing such kind of info on your blog.
Im really impressed by your blog.
Thank you.
OH FINALLY!
It's been a lifetime that I had NEVER understood how to insert spaces in editing: SHIFT+INST-DEL! (that's why there's inst, in fact, but I had never given weight to the fact that it could be a dual-function key)
I didn't even think it was planned. How I would like to get my old C64 back to try...
Thank you!
Among other things, I also have a real rarity for the C64: a speech recognition system, the Lis’Ner 1000 by MicroMint (1985), made by Steve Ciarcia (look for “Steve Ciarcia Circuit Cellar”), a sort of “ante-litteram” DSP that extracted a hash from the spoken speech sample from which the C64 could be trained to recognize up to 64 words.
This device was also produced for IBM and Apple II.
Only at the time I was 13 years old, and not having at that time a significant knowledge of English, I found it difficult to understand how it worked beyond “training” mode… and so I stopped using it, not without great disappointment.
Now if you’re curious about it, you can find some samples on E-Bay (should not be mine, as I lost it; don’t know if anyone else has ever found it…?)
“I halso had had” i meant
Il C64 non è così costoso da comprare… si trova su eBay o nei mercatini. In alternativa, puoi usare l’emulatore VICE.
I’ve never heard about this speech recognition system for C64. Thank you for sharing.
Yes. 🙂