If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

An attempted Qbasic Tutorial Part II

PART TWO: COMMENTING YOUR CODE, DOING CALUCLATIONS, MORE STUFF

Now, you have been making a couple simple programs on your own, right? Well, now, I’ll teach you how to comment your code. In Qbasic, there are two ways to do this. One is the apostrophe (‘) . The other is the REM command. The apostrophe is more versatile, because it can go on the same line as the code you are commenting, while the REM command has to go on it’s own separate line. The uses are like this:

CLS
‘This program started on 10/13/03
‘ written by slick8790
‘ This program displays a simple greeting
REM This is the other way to comment your code
PRINT “Hello, World” ‘pretty simple
END

However, the computer sees these instructions:

CLS
PRINT “Hello, World”
END

Use this if you want to document features, let yourself know about bugs, or just say anything.

Now, I’m assuming that you know the mathematical operators on a PC, right? + (plus), - (subtract), * (multiply), / (divide), and ^ (exponent). You can make any calculation you want, or even put a variable in as follow:

CLS
INPUT “Which number do you want multiplied by 5?” ; number
final = number * 5
PRINT “The answer is “; final; “.”
END
So you typed it in and got your answers, right? (You are typing these in, aren’t you?)

Now, lets play around with strings for a little bit. To make a string all lowercase use the command LCASE$(“STRING THAT YOU WANNA MAKE LOWERCASE”). Also, the uppercase command is UCASE$(“string you wanna make uppercase”) They are used like:

CLS
PRINT UCASE$(“ I like to make things capitalized “)
PRINT LCASE$(“ LOWERCASE IS GOOD TOO”)
END

Note: The letters don’t have to be in the opposite case, I just did that to illustrate the functions of that command

Also, there are commands for counting the amount of characters in a string. That is the LEN command. Syntax is ‘ LEN(Greetings from New Jersey!”) ‘ Used as:

\"Look, Doc, I spent last Tuesday watching fibers on my carpet. And the whole time I was watching my carpet, I was worrying that I, I might vomit. And the whole time, I was thinking, \"I\'m a grown man. I should know what goes on my head.\" And the more I thought about it... the more I realized that I should just blow my brains out and end it all. But then I thought, well, if I thought more about blowing my brains out... I start worrying about what that was going to do to my goddamn carpet. Okay, so, ah-he, that was a GOOD day, Doc. And, and I just want you to give me some pills and let me get on with my life. \" -Roy Waller