Tutorial 3
Welcome to the 3rd tutorial! In this tutorial, we will be talking
about some more $trings, and my favorite command...INPUT, and you will
learn a few others, so COME ON!!!!
First type in this program:
CLS
person1$="Big Bill"
IOU1=5.00
person2$="Tiny"
IOU2=10.00
person3$="Rocky"
IOU3=50.00
PRINT person1$
PRINT IOU1
PRINT person2$
PRINT IOU2
PRINT person3$
PRINT IOU3
Now, what you should have seen diplayed is a little I.O.U.
list, it should have printed out the first person, then below how much
that person owes. Then under that the second person, and how much he
owes....and so on.....You notice that we only stored the person as a
string, and we left the IOU as a variable. I think that you have the
right idea about what to do, so we are going to move on to the one and
only INPUT command!!! This command is probably the most useful when you
are just writing little programs like this, but it is most definitly,
the most fun one to use in a program!! Punch this in the keyboard:
CLS
INPUT "What is your name: "; name$
INPUT "How old are you: "; age$
PRINT "Hello ";name$;" You are ";age;" years old!"
This is a very good program to show us how to get input from something.
The program first clears the screen, then asks for your name, and wait
for someone to type one in. Then it will as for your age, and wait for
you to type one in, the it will display a little greeting, saying your
name, and your age! Now if we put a "," instead of a ";" in back of the
input statements..Ex. INPUT "What is your name: ";name$....to INPUT
"What is your name: ", name$, then it would get rid of the question
mark at the end of the question you are asking.
Now we are going to talk about a couple VERY IMPORTANT
commands...IF...THEN....ELSE. IF you ever decided to make a living off
of computer programs...you will need these commands, they are very much
needed in any game, program, ANYTHING!!!Type this in:
CLS
INPUT "What is your age: ", age
IF age < 18 THEN PRINT "You are too young!"
IF age > 18 THEN PRINT "You are too old!"
IF age = 18 THEN PRINT "You are good to go!"
Whoa!! Look at that!! Can you believe what you just did, you
actually almost created a security program!!(ALMOST) What you did, is
ask for an age and if it was over, or under, and then yuo displayed a
message.
When writing programs, you are going to need to know how to use
the less than , more than, etc. statements...so here they are,
<....Less than, >.....Greater than, =.....Equal to,
<=.....Less than or Equal to, >=.....Greater than or Equal to,
<>.....Not Equal to.
If you ever wanted to make a phone book, and address directory...here is an example:
CLS
INPUT "Name: ", name$
INPUT "Phone number: ", number$
INPUT "Address: ", address$
PRINT name$
PRINT address$
PRINT number$
So, there you have it...this is the end of the third tutorial...sad but true...See you on the other side!!!
If you have any questions at all you can mail me or you can mail me, go onto the next tutorial and be enriched!!
I am having difficulties with this page...for some odd reason the
greater than, less than symbals, are not turning out like I want them..