| Chapter 1 The basics of Qbasic |
||||||||||||||||||||
| Firstly, be glad that I am not asking you to look at my nice logo. Anyway, the first of all the commands you learn is the almighty CLS command. What does it do, you may ask. That is simple. It drops a nuke on the screen, erasing anything on it. Here's the magic word: |
||||||||||||||||||||
| CLS | ||||||||||||||||||||
| It isn't essential to start off yor program with this command, but I recommend it. Otherwise ,you might see some gunk on-screen when you start your program. | ||||||||||||||||||||
| Next, is the PRINT command.It doesn't print something thru the printer, rather it writes something on the screen.This is it: | ||||||||||||||||||||
| PRINT "QB RULES" | ||||||||||||||||||||
| Evidently,it writes whatever is inside the expression marks. | ||||||||||||||||||||
| Some of you may want to ask a persons name, age, credit card number, ID number, etc.You do that using the INPUT command.It's written below: | ||||||||||||||||||||
| INPUT "What is your credit card number"; ccn | ||||||||||||||||||||
| Firstly, you type in the message you want printed on the screen. Then ,you put a semi-colon followed by the variable (the variable in this case is 'ccn' without the quotes) you want the credit card number to be stored in.(Note: Use a $ sign at the end of the variable if it is going to contain text.e.g ccn$ = "ASD312346") |
||||||||||||||||||||
| Now, let's just say that you desire to write something at a specific location on the screen. Firstly, I've a question for you.Do you know Cartesian / x,y coordinates?. If you don't, learn it. You will use it alot in QBASIC.Anyway, to accomplish this oh-so tedious task,you use the LOCATE command. Here's the syntax: |
||||||||||||||||||||
| LOCATE 12,40 :PRINT "QBASIC RULES" | ||||||||||||||||||||
| So the sentence will be written at row 12, column 40 of the screen.Isn't that marvellous! | ||||||||||||||||||||
| Now here is something to add comments to your code. Use ' or :REM | ||||||||||||||||||||
| It goes something like this: | ||||||||||||||||||||
| PRINT "Thura" 'This is a comment PRINT "Thura " :REM This is also a comment |
||||||||||||||||||||
| The computer will write my name on screen, but the comments do nothing. Happy? | ||||||||||||||||||||
| Okay, so some of you want the program to start thinking a variable is a certain number.Do it like this: |
||||||||||||||||||||
| LET variablename = 24 | ||||||||||||||||||||
| For QB 4.5 ,you need not type the LET command. | ||||||||||||||||||||
| Take your time to understand this before you go on.Below is a present for you once you got the hang of it. |
||||||||||||||||||||