I've always wanted to start a topic to have a simple basic course for newbies. So I finally decided to set something up.
Let's start with the basics first
1) variables
2) output to the screen
3) user input
4) decisions
Variables
a=12345 print a
This assigns a value of 12345 to the variable name a
a$="hello world" print a$
In case you want to assign a string to a variable we use a $ at the end. So in this case a$
Now also try
print a,a$
You will see that a and a$ still both have the values
Output to the screen
Let's just limit ourselves to text output for now.
In the previous example we used 'print'. Print does exactly what it says... it prints to the screen
(in the next examples we type new to clear out the previous basic program that's in your memory. This can't be undone easily to use this with caution!
Anyway try this:
new 10 print "hello world":goto 10
To stop this push the ctrl and stop keys at the same time.
User Input
To get user input we use the command input here is an example:
new 10 print"What is your name";A$ 20 print "hello ";a$
Alternatively you can use lineinput instead of input
You can also read the keyboard input
new 10 print inkey$:goto 10
When you run push a few keys on the keyboard you'll see letters scroll up the screen.
To stop this push the ctrl and stop keys at the same time.
We can also get keyboard input for the joystick and cursor keys.
new 10 print stick(0):goto10
Push the cursor keys. To stop this push the ctrl and stop keys at the same time.
decisions
A program needs to make decisions on the input whic is given to it. Try this
new 10 input "give a number less than 10";a 11 if a<10 then print "thanks!" 12 if a=>10 then print "this is 10 or more!" 13 goto 10
Try giving in a few numbers ranging between 0 and 50.
To stop this push the ctrl and stop keys at the same time.
Now let's finish this lesson with a cool example:
new 100 SCREEN0:COLOR15,0,0 110 D=STICK(0):'keyboard 120 IF D=1 THEN A$="up" 130 IF D=5 THEN A$="down" 140 IF D=7 THEN A$="left" 150 IF D=3 THEN A$="right" 160 IF D=8 THEN A$="left up" 170 IF D=6 THEN A$="left down" 180 IF D=2 THEN A$="right up" 190 IF D=4 THEN A$="right down" 200 PRINT D,A$ 210 GOTO 110
Let me know what you think