Basic language programming course, #1

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).

Iscriviti al canale YouTube: Valoroso-IT. Retro tecnologia, Commodore, impianti stereo vintage, retro computer, esperimenti e prove.

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, Commodore children, C16 Commodore 16 gratis free video, Hello World

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.

The computer executes the instructions in sequence, REM PRINT INPUT GOTO, Basic language programming course, Commodore, Commodore 16, Commodore 64, Commodore 128, Commodore PET, Commodore Plus4, Commodore Vic20, C16 C128 C64, IBM DOS MicroSoft GWBASIC

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.

Dividere istruzioni comandi stessa riga due punti, ":", Corso tutorial programmazione linguaggio Basic Commodore, Commodore 16, Commodore 64, Commodore 128, Commodore PET, Commodore Plus4, Commodore Vic20, C16 C128 C64, IBM DOS MicroSoft GWBASIC

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.

Instruction command INPUT variable string A$, dollar, "$", Basic language programming course Commodore QB64, Commodore 16, Commodore 64, Commodore 128, Commodore PET, Commodore Plus4, Commodore Vic20, C16 C128 C64, IBM DOS MicroSoft GWBASIC, char sequence, max length variable names

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.

Iscriviti al gruppo Facebook. Retro tecnologia, Commodore, impianti stereo vintage, retro computer, esperimenti e prove.
Instruction command PRINT strings chain, semicolon ";", tutorial Basic language programming course Commodore, Commodore 16, Commodore 64, Commodore 128, Commodore PET, Commodore Plus4, Commodore Vic20, C16 C128 C64, IBM DOS MicroSoft GWBASIC, free

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).

Command sequence GOTO GOSUB, Basic language programming course Commodore, Commodore 16, Commodore 64, Commodore 128, Commodore PET, Commodore Plus4, Commodore Vic20, C16 C128 C64, IBM DOS MicroSoft GWBASIC, jump

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.

Running a program in Basic, Commodore, C16 C128 C64 PET Vic20 GWBASIC, Hello World

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.
LIST command, instructions list display show BasicCommodore, Commodore 16, Commodore 64, Commodore 128, Commodore PET, Commodore Plus4, Commodore Vic20, C16 C128 C64, IBM DOS MicroSoft GWBASIC

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:

  • CORSO-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;
  • CORSO-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: nel video tutorial, la SID music è Noisy Pillars di Jeroen Tel.

Iscriviti al canale YouTube: Valoroso-IT. Retro tecnologia, Commodore, impianti stereo vintage, retro computer, esperimenti e prove.

Ti piace questa pagina? Condividila:

Pubblicato in Tutorials.

Un commento

Lascia un commento

Il tuo indirizzo email non sarà pubblicato.

Immagine CAPTCHA

*