Computer Science Education | Programming Language Tutorials For Beginners

QBASIC TUTORIAL 2 - CLS

CLEAR SCREEN COMMAND (CLS).


Wouldn't it be nice to be able to clear off the screen before printing a new line? "CLS", which stands for Clears Screen, is just the ticket. You will need to put CLS at the very top of your program to clear the screen before you print anything.  
Inserting a new line at the top.  
To make CLS the first line of your program, follow these steps: 
Press the <Home> key to get to the beginning of the current line. 
Press the <Up Arrow> key once or twice to get the cursor to the top of the program. 
Press the <Enter> key to get a new line. 
Press the <Up Arrow> key once to get the cursor on the new blank line. 
Type CLS  

Now your program should look like this:  

     CLS  
    PRINT "Welcome to QBasics Tutorial 2."  


Remember to always save your program before running it. Use the Save As command and use a different path to change the name. 

Now run it. Remember, click on Run and then Start in QBASIC's menu. You can also run the program by pressing <F5> 

That's much better. Only one message is on the screen, which is the way it should be. 
SHORTCUT ? 
As a cool shortcut use ? For PRINT. Try it. Press <Enter> to start typing on a new line. Now type this: 

     ? "Programming is fun."

And  press <Enter> again. Now your program should look like this:   

     CLS  
     PRINT "Welcome to QBasics Tutorial 2."  
     PRINT "Programming is fun"  


Isn't that nice? The ? Becomes the word PRINT. That should save us a lot of typing in the long run.  

You can try running the program again. You should see something like this:  


What You Have Learned in tutorial 2:
CLS
?

Share:

No comments:

Post a Comment

Popular Posts

Elitcode - Learning Start Here

Elitcode Blog Archive