0% found this document useful (0 votes)
51 views2 pages

BASIC Programming/Beginning Basic/Print, CLS, and End

This document discusses the PRINT, CLS, and END commands in BASIC programming. It provides an example program that uses these commands and then explains what each one does. PRINT writes text to the screen on a new line each time. CLS clears anything printed to the screen. END stops the program from running any additional lines of code. The example demonstrates using these commands to print messages, clear the display, and end the program.

Uploaded by

anani samson
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
51 views2 pages

BASIC Programming/Beginning Basic/Print, CLS, and End

This document discusses the PRINT, CLS, and END commands in BASIC programming. It provides an example program that uses these commands and then explains what each one does. PRINT writes text to the screen on a new line each time. CLS clears anything printed to the screen. END stops the program from running any additional lines of code. The example demonstrates using these commands to print messages, clear the display, and end the program.

Uploaded by

anani samson
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 2

BASIC Programming/Beginning

BASIC/PRINT, CLS, and END


< BASIC Programming
Jump to navigation Jump to search

BASIC Programming > Beginning BASIC > Your First Program

Introduction
In the previous code example, we wrote your first BASIC program. In it, you saw examples of
PRINT, CLS, and END commands. Their roles in the program may or may not have been
apparent at the time, but, as they're so vital to the BASIC language, they will be discussed
here.

10 CLS
20 PRINT "Helloooooooooooooo, world!"
30 PRINT "I'm making the sample program clear and understandable."
40 PRINT "This text is being printed via the PRINT command."
50 PRINT "On the next line, I'll use CLS, which will clear everything I
just printed, so you won't even see the preceding text."
55 PRINT "Also, you can't give CLS a line to PRINT; it won't actually do
anything"
60 CLS "These words actually do nothing; they do not PRINT or anything."
70 PRINT "Finally, on line 80, I'll use END, which will keep me from
reaching line 90."
80 END "Like CLS, putting a string here does nothing; it does not PRINT or
anything."
90 PRINT "this is not really my answer."

Output
(CLS)
Helloooooooooooooo, world!"
I'm making the sample program clear and understandable."
This text is being printed via the PRINT command."
On the next line, I'll use CLS, which will clear everything I just printed,
so you won't even see the preceding text."
Also, you can't give CLS a line to PRINT; it won't actually do anything"
(CLS)
Finally, on line 80, I'll use END, which will keep me from reaching line
90."
(END)

-Program end-

Discussion
From that example, it's fairly easy to deduce what each command does.

CLS
An abbreviation that stands for the words CLear Screen. In the above program, when
you used CLS on line 60, all of the words that were printed to the screen were wiped
away.
PRINT
Writes to the screen. There are commands for printing to other things, like a printer,
but that's to be discussed later. Each new PRINT command will start printing on a new
line. To insert a blank line, don't specify a string to print. The syntax for "PRINT" is:
PRINT "[whatever you want to be printed here]"
END
It stops the program at that line; that is, anything that's added after that won't show.
That's why the PRINT command on line 90 didn't print anything. The END command
can be included in control structures to end the program if a condition is met. This will
be discussed with control structures.

What is happening?

1. Line 10 the display is cleared.


2. Lines 20 through 50 print text to the screen.
3. Line 60 clears the display.
4. Line 70 shows the message you should see after you run this program.
5. Line 80 ends the program.
6. Line 90 shows that an END statement stops the program. No instruction following an
END statement is executed.

Given the state of computer speed today you should not see the paragraph displayed by lines
20 through 50, it should be cleared by the CLS statement on Line 60 before you have a chance
to see it. If you slow the program down you can see the program write the message to the
screen. Line 70 is then written to the screen/display then Line 80 stops everything. Line 90
never, ever runs.

Next: Beginning
Previous: Beginning
Index BASIC/Variables and Data
BASIC/Your First Program
Types
Category:

 Book:BASIC Programming

You might also like