Heaney

Soft


HeaneySoft's BASIC Tutorial
Section 3: Output Statements


There are two output statements we will be learning about in this section: Disp and Output. Remember to have your calculator by your side, ready to program.

Disp:
Disp is the more basic of the two statements. Whatever you tell Disp to output, it will simply output it on the next available row of characters on the screen. To use Disp you first need to find it. Go back to the I/O directory and Disp is the third one from the top. After the Disp statement there is a space already for you, now just put a quotation " followed by 16 characters or less, and then an end quotation ". It will look like this:

:Disp "MESSAGE IS HERE"

When the program is run MESSAGE IS HERE will be shown on the next available line. The screen you are viewing at this time is called the Home screen. When you ran the program just now you probably saw this on the Home screen:

prgm(whatever you called it)
MESSAGE IS HERE

I don't know about you, but when I run a program I don't want to see anything else other than the output. So, to clear the Home screen from the program, we use the ClrHome statement, also found in the I/O directory. Now the program will look like this:

:ClrHome
:Disp "MESSAGE IS HERE"

Now when you run it, all you will see is MESSAGE IS HERE. Lets say you want to output more than one line, you could use the Disp statement more than once, like this:

:ClrHome
:Disp "IM LEARNING TO"
:Disp "PROGRAM IN BASIC"

But to save time and button pushing, a single Disp statement can be used to output as many lines as you like (but the Home screen only has room for 7 before it starts scrolling, so I always stop there). To do this, just put a comma after the end quotation, followed by another quotation, then your message, then an end quotation. It looks like this:

:ClrHome
:Disp "IM LEARNING TO","PROGRAM IN BASIC"

Now we'll learn about the Output statement.

Output:
The nice thing about this statement is you can put text anywhere you want on the Home screen. The Home screen is made up of 8 rows of 16 characters, to use the Output statement just tell it the row and character you want to start at. So it goes Output(row, column, output). Lets say were doing the multiplication program and we want to tell the user what the answer is, stored in variable C. The program would look something like this:

:ClrHome
:Disp "ANSWER:"
:Output(1,9,C)

So lets say the answer (C) is 10. When we run this program it will say ANSWER: 10. As you can see, the answer was outputted at the ninth character of the first row. This makes things a lot easier, and a lot nicer looking. Hopefully all this stuff seems pretty simple to you, if not, you can always click the link at the bottom of this page to ask me a question. Now we're going to start getting into some tougher stuff.

Section 2 | Index | Section 4

Comments, Questions, or Ideas: Click Here | Home

Copyright © 2004 HeaneySoft