10th Part: "Nostalgia" "Old" Basic Language interpreters, Commodore 64 Basic Interpreter # 1.

Published:

Updated:

Entering Data.

-----------------------

--------------------------

The INPUT keyword

This keyword prints a ? mark and positions the cursor 2 spaces to the right of the ?.

Samples:

String variable A$

10 PRINT "Input the name of a fruit":INPUT A$
20 PRINT "You printed "A$

------------


                         **** COMMODORE 64 BASIC V2 ****

                      64K RAM SYSTEM  38911 BASIC BYTES FREE

READY.
10 PRINT "Input the name of a fruit":INPUT A$
20 PRINT "You printed "A$
RUN
Input the name of a fruit
? Banana

You printed Banana

READY.

----------

Numeric variable A

10 PRINT"Enter a number between 1 and 10": INPUT A
20 PRINT "You printed" A

------------------


                         **** COMMODORE 64 BASIC V2 ****

                      64K RAM SYSTEM  38911 BASIC BYTES FREE

READY.
10 PRINT"Enter a number between 1 and 10": INPUT A
20 PRINT "You printed" A
RUN
Enter a number between 1 and 10
? 4

You printed 4

READY.

-------


                         **** COMMODORE 64 BASIC V2 ****

                      64K RAM SYSTEM  38911 BASIC BYTES FREE

READY.

After reading and trying several things I came out with these, it seems to me that people who use the INPUT command don't give enough information to people on their programs so they will know what to use as INPUT and also maybe about the output.


1 PRINT "Type 2 numbers between 1 and 100"
2 PRINT "One number at a time"
3 PRINT "And press the Enter key after typing each number"
4 INPUT "First Number "; A
5 INPUT "Second Number "; B
6 PRINT "First"A ", " "Second"B
RUN
Type 2 numbers between 1 and 100
One number at a time
And press the Enter key after typing each number
First Number ? 47

Second Number ? 16

First 47 , Second 16

READY.

That program of course didn't do anything as it is, but it is just a basic example.

---------------

EXAMPLE 1:
100 INPUT A
110 INPUT B,C,D
120 INPUT "PROMPT";E

                                                         24
~
                       When this program runs, the question mark appears to prompt
the operator that the VIC is expecting an input for line 100. Any
number typed in goes into A, for later use in the program. If the
answer typed was not a number, the ?REDO FROM START
message appears, which means that a string was received when a
number was expected. If the operator just hit RETURN without
typing anything, the variable's value doesn't change.
                       Now the next question mark, for line 110, appears. If we type only
one number and hit RETURN, the VIC will now display 2 question
marks (??), which means that more input is required. You can just
type as many inputs as you need separated by commas, which
prevents the double question mark from appearing. If you type
more data than the INPUT statement requested, the ?EXTRA
IGNORED message appears, which means that the extra items
you typed were not put into any variables.
                       Line 120 displays the word PROMPT before the question mark
appears. The semicolon is required between the prompt and any
list of variables. Note: The only way to end a program during
an INPUT statement is to hold down the RUN/STOP key and
hit RESTORE.

EXAMPLE 2:
10 PRINT "INPUT A WORD":INPUT A$
20 PRINT "YOUR INPUT WAS"A$
30 GOTO 10

------------------

That is simple stuff, but when used in programs with other keyword commands the "Program's logic becomes more complicated"

That might be seen later maybe.

This is all on this for now.

Once you know how to use, the keyword commands by themselves more or less, then you can try to put them together into longer and more complex programs, it is all about the logic of what you want done and or trying to do.

Look at small and also at long programs and try to follow the "Commands Logic", that is the programs' logic, in other words what is being done in "Execution of the commands" and how it is being done, for some people like maybe me it might be easier said than done, so it might be better to start slow and small.

--------------

There are many views, but as Todd says, it might mostly be due to the search engines always making many hits as they index all the data on web pages all over the Internet.

I wonder if some people are really reading this posts and trying to learn from them, you know, it is not very easy to come by data such as this, nowdays mostly it being such an old kind of info, not so easy to find and yet it might be basic programming info and still of some use, after all people have to start somewhere and this is not as hard nor as strange as some other programming stuff.

After all many people are still using DOS and some form of BASIC programming language.

From what I have heard about a lot can still be done with DOS and some form of BASIC by those who are good about it and who also might be good with Math.

----------------

I also just made this:


    **** COMMODORE 64 BASIC V2 ****

 64K RAM SYSTEM  38911 BASIC BYTES FREE

READY.
1 PRINT "Type 2 numbers between 1 and 100"
2 PRINT "One number at a time"
3 PRINT "And press the Enter key after typing each number"
4 INPUT "First Number "; A
5 INPUT "Second Number "; B
6 PRINT "First"A ", " "Second"B
7 C = A+B
8 PRINT " 1ST + 2ND ="; C
RUN
Type 2 numbers between 1 and 100
One number at a time
And press the Enter key after typing each number
First Number ? 35

Second Number ? 60

First 35 , Second 60
 1ST + 2ND = 95

READY.

It adds the 2 inputs, this is my first real program nowdays, but on the old days maybe on the 80s, I did make 1 or more programs, not too complicated,  better than this one, of more use, but nothing really great, it was with the Commodore 64, since then I forgot all that I knew about Basic, but I am relearning a little just now, while making these many posts.

Back then I also leared some about assembly language on the C-64, it was not as hard as some people think that it is, at least for the C-64, I probably would not try that with a 386 + Pc, I only learned and tried some little things, I already forgot all about what little I knew about Assembler, the instructions, decimal, hexadecimal and machine code.

I made it so you can see how things can be made of more use and also more complicated, always make the logic in your mind and or on paper or Note or WordPad and then try it to see if it works and how, if not make changes until it works.

----------

Some of the stuff that is learned with Commore basic works with other basic languages, either as it is or changed some.

-----------------------

I just made the program of more use:

1 PRINT "Type 2 numbers between 1 and 100"
2 PRINT "One number at a time"
3 PRINT "And press the Enter key after typing each number"
4 INPUT "First Number "; A
5 INPUT "Second Number "; B
6 PRINT "First"A ", " "Second"B
7 C = A+B
8 PRINT " 1ST + 2ND ="; C
9 REM Here you would put a code command to clear the screen
10 GOTO 1

--------------

Now it is on a non-ending loop, so you can keep on adding numbers, it only needs the Screen Clear Command that the C-64 has, but that doesn't seem to work with this C-64 basic interpreter.

---------------------------------------

I Just thought about something else and could not let it go, so I have to add it to this:

I just remade the program so it is a sort of adding machine, as I said it is all about "Logic of execution of commands"

If it had the Screen Clear Command on it, it would only show the last results of the totals of the additions, but maybe that is not possible to do here with this interpreter, anyhow as it is, is like having a printing tape so we can check the numbers that were added, just in case of any mistakes:


                **** COMMODORE 64 BASIC V2 ****

             64K RAM SYSTEM  38911 BASIC BYTES FREE

READY.
1 PRINT "Type a number"
3 PRINT "And press the Enter key after typing the number"
4 INPUT A
5 A = A + C
6 PRINT A
7 C = A
10 GOTO 1
RUN
Type a number
And press the Enter key after typing the number
? 1

             1
Type a number
And press the Enter key after typing the number
? 1

             2
Type a number
And press the Enter key after typing the number
? 1

             3
Type a number
And press the Enter key after typing the number
? 1

             4
Type a number
And press the Enter key after typing the number
? 1

             5
Type a number
And press the Enter key after typing the number
? 0

             5
Type a number
And press the Enter key after typing the number
? 5

             10
Type a number
And press the Enter key after typing the number
? 5

             15
Type a number
And press the Enter key after typing the number
? 5

             20
Type a number
And press the Enter key after typing the number
? 5

             25
Type a number
And press the Enter key after typing the number
?

-----------------------

Not too bad for somebody who knows next to nothing about programming?

Try it yourself:

0 REM Adding Machine.

1 PRINT "Type a number"
3 PRINT "And press the Enter key after typing the number"
4 INPUT A
5 A = A + C
6 PRINT  "Totals"A
7 C = A
10 GOTO 1

--------------------

The more that you learn, the more that you will be able to do.

--------------

2 PRINT "This is the front end of a very simple unfinished calculator"
4 PRINT "1 = + , 2 = - , 3 = x , 4 = /"
6 PRINT "Type: 1, 2, 3 OR 4"
8 INPUT "Type one of the 4 functions and then press Enter ";X
30 IF X = 1 THEN 50
31 IF X = 2 THEN 60
32 IF X = 3 THEN 70
33 IF X = 4 THEN 80
34 END
50 PRINT "Addition": REM GOTO (Line number)
55 END
60 PRINT "Substraction": REM GOTO (Line number)
65 END
70 PRINT "Multiplication": REM GOTO (Line number)
75 END
80 PRINT "Division": REM GOTO (Line number)
85 END

----------

Try it but as I said it is unfinished it is only the "Front" or first portion, the rest might follow sometime later maybe.

It would use maybe routines such as the one on the program before this one above.

-------------------

It uses very simple logic, but also effective, can you follow it and can you also follow the next unfinished portions (Routines)?

By the way for this particular program those who know how, don't post your own routines , later I want to try to figure them out myself, once I post mine when and if I do then you can post your own, for now keep them to yourself.

--------------------------

I just added the "Addition Routine" portion to it:

1 REM Front or Top Routine

2 PRINT "This is the front end of a very simple unfinished calculator"
4 PRINT "1 = + , 2 = - , 3 = x , 4 = /"
6 PRINT "Type: 1, 2, 3 OR 4"
8 INPUT "Type one of the 4 functions and then press Enter ";X
30 IF X = 1 THEN 50
31 IF X = 2 THEN 60
32 IF X = 3 THEN 70
33 IF X = 4 THEN 80
34 END
50 PRINT "Addition": GOTO 100
55 END
60 PRINT "Substraction"
65 END
70 PRINT "Multiplication"
75 END
80 PRINT "Division"
85 END

90 REM Calculator Addition Routine
100 PRINT "Type a number"
102 PRINT "And press the Enter key after typing the number"
104 INPUT "To use other function enter 0 (Zero) "; A
106 IF A = 0 THEN 4
108 A = A + C
110 PRINT  "Totals"A
112 C = A
114 GOTO 100

Can you still see the execution logic? It is very easy!

----------------------


    **** COMMODORE 64 BASIC V2 ****

 64K RAM SYSTEM  38911 BASIC BYTES FREE

READY.
1 REM Front or Top Routine

2 PRINT "This is the front end of a very simple unfinished calculator"
4 PRINT "1 = + , 2 = - , 3 = x , 4 = /"
6 PRINT "Type: 1, 2, 3 OR 4"
8 INPUT "Type one of the 4 functions and then press Enter ";X
30 IF X = 1 THEN 50
31 IF X = 2 THEN 60
32 IF X = 3 THEN 70
33 IF X = 4 THEN 80
34 END
50 PRINT "Addition": GOTO 100
55 END
60 PRINT "Substraction"
65 END
70 PRINT "Multiplication"
75 END
80 PRINT "Division"
85 END

90 REM Calculator Addition Routine
100 PRINT "Type a number"
102 PRINT "And press the Enter key after typing the number"
104 INPUT "To use other function enter 0 (Zero) "; A
106 IF A = 0 THEN 4
108 A = A + C
110 PRINT  "Totals"A
112 C = A
114 GOTO 100
RUN
This is the front end of a very simple unfinished calculator
1 = + , 2 = - , 3 = x , 4 = /
Type: 1, 2, 3 OR 4
Type one of the 4 functions and then press Enter ? 1

Addition
Type a number
And press the Enter key after typing the number
To use other function enter 0 (Zero) ? 1

Totals 1
Type a number
And press the Enter key after typing the number
To use other function enter 0 (Zero) ? 4

Totals 5
Type a number
And press the Enter key after typing the number
To use other function enter 0 (Zero) ? 4

Totals 9
Type a number
And press the Enter key after typing the number
To use other function enter 0 (Zero) ? 10

Totals 19
Type a number
And press the Enter key after typing the number
To use other function enter 0 (Zero) ? 0

1 = + , 2 = - , 3 = x , 4 = /
Type: 1, 2, 3 OR 4
Type one of the 4 functions and then press Enter ? 2

Substraction

READY.

------------

Well now I seem to have 2 of the calculator's routines working, the addition and the substraction, this is hard for me as I am just learning or relearning how to do such things, use the Commodore interpreter and give them a try and see if you can follow the "Execution" logic, I even added some "Safe Guards" for "Fool Proofing", but only up to a reason able point:

While some others can do much better, this is not bad for somebody kind of new at this, like me, I know some people can do a lot worse than this, maybe some other time I will try to add the multiplication and the division routines, one of them at a time, it is hard for me to make such things.

So far it looks as if addition and substraction are working O.K.

1 REM Front or Top Routine
2 PRINT "This is the front end of a very simple unfinished calculator"
4 PRINT "1 = + , 2 = - , 3 = x , 4 = /"
6 PRINT "Type: 1, 2, 3 OR 4"
8 INPUT "Type one of the 4 functions and then press Enter ";X
30 IF X = 1 THEN 50
31 IF X = 2 THEN 60
32 IF X = 3 THEN 70
33 IF X = 4 THEN 80
34 IF X < 1 THEN 40
35 IF X > 4 THEN 40
36 REM
40 PRINT "Wrong Number, Try again": GOTO 4
45 REM
50 PRINT "Addition": GOTO 100
55 REM
60 PRINT "Substraction": GOTO 200
65 REM
70 PRINT "Multiplication is unsupported for now" : GOTO 2
75 END
80 PRINT "Division is unsupported for now" : GOTO 2
85 END
90 REM Calculator Addition Routine
100 PRINT "Right now you have": PRINT C
101 PRINT "Type a number"
102 PRINT "And press the Enter key after typing the number"
104 INPUT "To use other function enter 0 (Zero) "; A
106 IF A = 0 THEN 4
108 A = A + C
112 C = A
114 GOTO 100
115 REM
200 REM Substraction Routine
201 PRINT "Right now you have": PRINT C
202 PRINT "Type a number"
203 PRINT "And press the Enter key after typing the number"
204 INPUT "To use other function enter 0 (Zero) "; A
206 IF A = 0 THEN 4
207 IF C > A THEN 210
208 IF C < A THEN 213
210 C = C - A
211 GOTO 201
212 END
213 PRINT "Can't substract from a lower number"
214 GOTO 201
215 END


Entry #337

Comments

Avatar LANTERN -
#1
A download link to the calculator as it is right now there unfinished and only having the addition and subtraction modes working so you can see that such can be compiled to .exe file and it works:

http://www.filedropper.com/calculatoronly-

Copy and then paste onto the browser's window.
Avatar LANTERN -
#2
That didn't work I am now trying this other place:

http://www.filefactory.com/file/cbcb753/n/CalculatorOnly+-.exe
Avatar LANTERN -
#3
The second download site worked O.K. but it was a lot of trouble downloading it from there, some other time I will look for a better place, for other such files if I make them.
Avatar LANTERN -
#4
Doesn't look as if people are interested in this posts about old basic programming, I might just quit posting them and maybe keep on trying to learn by myself, this is the wrong place for this anyway this being a lottery forum and not a programming forum.
So far as seen I am doing well enough on this all by myself, but this is just text based programming so far and it is very limited, but there are other basic interpreters and more advanced old basics.

Post a Comment

Please Log In

To use this feature you must be logged into your Lottery Post account.

Not a member yet?

If you don't yet have a Lottery Post account, it's simple and free to create one! Just tap the Register button and after a quick process you'll be part of our lottery community.

Register