Programming Qbasic Part Two

Ok, ready to take step on next level? This time, ill talk a bit less at start and give you a new code. You probably remember what to do with it =)

INPUT "Write your name and press ENTER" ;Name$
PRINT "Hello" ;Name$

Ok, not mutch anything new? There is INPUT and some ;Name$ also. Let me comment it and it might look better.

CLS ' Clears the screen.
INPUT "Write your name and press ENTER" ;Name$ ' Ask's you to write your name and save's what you typed on Name$
PRINT "Hello" ;Name$ ' Print's Hello and what you type earlier on screen.
END ' Remember what this does?

So what are these two, INPUT and ;Name$ ?

INPUT is some how same thing than PRINT expect is way different =) QBasic wait's after INPUT you to press ENTER before it continues forward. Other thing INPUT does is that you can save some text or numbers in variables with it easily.

INPUT "Here is what is going to be printed on screen" 'QBasic stops here until you press ENTER. ;Name$ 
'This is where your possible typing's will be saved before you pressed ENTER.

So if you don't type anything and just press ENTER then there is nothing to save on Name$. I bet you figured all ready how that PRINT "Hello" ;Name$ works. Instead of Name$ try use Myname$ or something else. You probably gona notice that in both lines you have to be exactly same variables.

INPUT "Write your name and press ENTER" ; Myname$
PRINT "Hello" ;Name$

Yah, that's not working. Ok, I don't think that we need to go thru this program any more. You are clever enough to figure out how it works and what those lines does. And now when we are learned some of the really basic commands we gona reach lot's of higher on next lesson.

Ill throw you some more complex looking code and comment it. Of course ill explain it also but there is more things you need to figure out your self. It's the best way to learn. Lesson 3 will include things how to place your text's on certain place of screen. How to ask more than just a name and some calculating things.

You'l see then =)

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.