The CLR keyword
It clears out variables that have been defined.
Undimensions any arrays.
And restores the data pointer back to the beginning
The same thing is done by the use of the:
RUN, LOAD and the NEW commands.
It is not the same as the CLR-Home Key which clears the screen.
20 C = 90
30 PRINT C
It printed 0 because CLR cleared C from 90 down to 0.
LET as said before is an optional command as it was said before.
BASIC remembers the values that have been assigned to variables using the LET keyword command.
But as said those values are deleted when one of these is or are used:
CLR or CLEAR
Also if a variable is used before it is given a value its value will be Zero-0
Like type on the BASIC interpreter:
It is the same as:
10 PRINT A
RUN (Or RUN 10)
Next I will show the INPUT, the IF-THEN and the GOTO statements:
5 PRINT "Enter a number"
10 INPUT B
20 IF B = 0 THEN 50
30 PRINT "Non Zero"
40 GOTO 5
50 PRINT "Zero"
60 GOTO 5
It is in a non-ending loop, it doesn't END.
The original program didn't have line 5 on it, I added that to it, otherwise a person would not know what the program wanted as an INPUT as it would just PRINT and show a ?
Many or most of these simple programs should run on many old BASIC interpreters.
= Equal to
> Greater than
< Less than
<> Not equal to
<= Less than or equal to
=> Greater than or equal to
5 PRINT "INPUT numbers then press Enter-Return"
10 INPUT A
15 INPUT B
20 IF A<=B THEN 50
30 PRINT "A is bigger"
40 GOTO 5
50 IF A<B THEN 80
60 PRINT "They are the same"
70 GOTO 5
80 PRINT "B is bigger"
90 GOTO 5
Beware of possible mistakes.
Try to follow the logic of how the program executes the commands on the lines, programming is all about Logic.
RUN the programs a few times and play with them.
I added line # 5 as it was not on the original program.
Back to variables
We can assign:
An Integer number or:
A Floating Point Number or:
A Text String to a Variable.
The % symbol following a Variable indicates that the variable represents an integer number:
THe $ Following the Variable tell that the variable represents a Text String:
Floating point variables follow the same format, I don't quite understand that about floating point variables, but later I will try to read on that when I am ready to.
First of all these all is basic stuff and might be of help for learning any basic language old or new
A variable name can have one or two characters as basic looks at the first 2 characters on a variable, those are the ones that matter.
The very first character must be a letter any-one of them from A to Z.
The second character can be any-one character either a single letter from A to Z or any single digit from 0 to 9, one or the other.
The third character will be either a % or a $, to indicate either an Integer or a text string.
You can use more than 3 character, but besides the % and the $, basic will only look at the very first two characters:
So AL% and ALFRED% will be exactly the same to the computer or to the basic interpreter.
The last rule is that Variables can't contain or have in them any BASIC reserved keywords such as: GOTO, RUN, Etc.
So as I said before a person should get familiar with the BASIC keywords that the BASIC that he is using has on it.
I go very slow and also repeat stuff, so this is all for this post, because most of us also have other things to do than to make and or read my posts and I want to make sure that both myself and you more or less understand what I am posting about, after all many like myself might be new or almost completely new to BASIC programming, or we might have forgotten most of what little we knew about old BASIC long ago.
Better read the 2 books that I posted for download time ago on this new thread.
Well more later, now the very basic stuff first and the Commodore 64 Basic Stuff first as there might be more information about C 64 programming than there is for other basics and they might be all kind of similar to each other anyway and this stuff might be nice to learn before trying to learn how to program with newer BASICS.
Besides many of the C 64 emulators are free and there are also old DOS BASIC interpreters that are kind of free.
Did you not already download some of them?
And there are even maybe a few more, but more on that later.