How to BASIC Program

This will teach you how to use BASIC Programming programs and what different functions do. (Some programs require you to type (10 home) for the first line.)

Numbering
First off, on some programs, such as Chipmunk BASIC, you need to add numbers to place the text. If you make a mistake in these kinds of programs, simply retype the number and fix what you want after it and press 'Enter'.
e.g.
10 print "Helo!" 'Enter'

Oops! I spelled 'Hello' wrong
retype:
10 print "Hello!" 'Enter'

(You do not have to type the 'Enter's; push the 'Enter' key.)
Notive how there in print with text in ("")'s. We will get to that later.
If you want to delete line of text, just type the number and press 'Enter'.
e.g.
10 print "Hello" 'Enter'
20 print "Hello" 'Enter'

Oops! I typed two lines of "Hello"s and I only need one.
retype:
20 'Enter'

You may use numbers such as 1 and 11. Usually you do that when you are making a list of answers or if you make a mistake between numbers. (Some programs require you to type ‘10 home’ for the first line. Also, sometime the last line must # and “end”.)

Printing
To print words onto a BASIC Program, type the number, type 'print' then "TEXT HERE" 'Enter'. Pretty basic. This will make it so you can add passages or questions to 'insert' answers that you can bring back in a program later. See the 'Inserting' section to learn what this is.

Inserting
If you want to ask a question and you want the user of the program to type in the answer, then you can use the 'insert' command.
e.g. 1
10 print "What is your name?"
20 insert a$

e.g. 2
10 print "How old are you?"
20 insert a

The difference between ‘a$’ and ‘a’ is that ‘a$’ is usually for word values, and ‘a’ would be for # values. It could be anything. You could do insert ‘pie’ or insert ‘pie$’ for the answer to favorite types of pie. If you want to bring up the value again, you put the a/a$ on a print line outside of (“”)’s.
e.g.
10 print "What is your name?"
20 insert a$
30 “Oh so you name is ” a$ “.”

If you want to make it so that there is a space between the word and the sentence is (“”)’s.

30 Oh so your name is” a$ (Let’s say for the name I typed Jake . Notice that there is no space between is and (”). When you run the program, it will show as:
Oh so your name isJake.
The “.” is to insert the period after the name.
^The same goes for the number values^

"If"'s, “Goto”’s, and "then"'s
If you want to make it so that you want specific things as answers, then use the ‘if’ command. The ‘goto’ command is for skipping to certain lines.
e.g.
10 print “What is 2+2?”
20 insert a
30 if a = 4 then goto 60
40 print “I’m sorry but that’s not right! Try again”
50 goto 10
60 print “Correct!”

It asks you what is 2+2. The answer is obviously 4. If ‘a’ = 4, then it will send you to line 60, which says “Correct!” Typing 3, 5, or any other wrong answers will say that you are wrong and it will send you back to line 10, where it will ask you what 2+2 is again.

If you want to make different positive and negative answers, such as yes and know, do something like the following:
e.g.
10 home
20 print "Hello, how are you?";a$
22 input a$
30 goto 50
40 print "How are you?"
41 input a$
50 if a$ = "good" then goto 80
51 if a$ = "not too bad" then goto 80
52 if a$ = "great" then goto 80
53 if a$ = "awsome" then goto 80
54 if a$ = "excellent" then goto 80
55 if a$= “fine” then goto 80
61 if a$ = "bad" then goto 90
62 if a$ = "not to good" then goto 90
63 if a$ = "horrible" then goto 90
64 if a$ = "I've been better" then goto 90
70 goto 100
80 print "Oh, well that's good!"
81 goto 110
90 print "Oh, well I hope you feel better."
91 goto 110
100 print "What was that? I didn't hear what you said."
102 goto 40
110 end

(This is an example from a program that I am currently programming, which I will give you in the end.)

By answer in a way like ‘good’ or ‘great’, it will send you to line 80, which will say “Oh, well that’s good!” and send you to the end. By answering in a way like ‘bad’ or ‘not to good’, it will send you to line 90, which will say “Oh, well I hope you feel better”and send you to the end. The goto 80 and goto 90 commands skip over line 70. If there is an answer other the answers that are valid, it will not go to 80 or 90, but it will continue to 70 which will send you to 100 which will say “What was that? I didn't hear what you said." It will proceed to line 102, which will send you back to line 40, which, again, will ask how you are. This works out and, unless you do not type in valid answers, the program will eventually come to an end.

List and Run
The list command will put everything that you typed bad into order. Let’s go back to the ‘Numbering’. Look at the example back in numbering:
e.g.
10 print "Helo!"

Oops! I spelled 'Hello' wrong
retype:
10 print "Hello!"
list

Then it should say under it:

10 print “Hello!”

Conclusion and Editors
I hope this makes you BASIC Programming much easier for you.
If you edit this page, please add your user-name bellow.

JakeEMan (Starter)
 
< Prev   Next >