Home Page


BASIC Handbook

Basic2 Commands
Disk Drives
PEEK's and POKE's
RAM Memory Map
ROM Memory Map
Screen Display
Sprite
ASCII and CHR$ Codes

eMail
email5-commodorecheetah.co.uk

Note: You will need to replace the '-' with the @ symbol.
This is to minimize spam.

My BASIC Quick Reference Guide

PRINT
Abbreviation:

TYPE: Statement
FORMAT: PRINT [<variable>][<,/;><variable>]...

Action: The PRINT statement is normally used to write data items to the screen. However, the CMD statement may be used to re-direct that output to any other device in the system. The <variable(s)> in the output-list are expressions of any type. If no output-list is present, a blank line is printed. The position of each printed item is determined by the punctuation used to separate items in the output-list.

The punctuation characters that you can use are blanks, commas, or semicolons. The 80-character logical screen line is divided into 8 print zones of 10 spaces each. In the list of expressions, a comma causes the next value to be printed at the beginning of the next zone. A semicolon causes the next value to be printed immediately following the previous value. However, there are two exceptions to this rule:

1) Numeric items are followed by an added space.
2) Positive numbers have a space preceding them.

When you use blanks or no punctuation between string constants or variable names it has the same effect as a semicolon. However, blanks between a string and a numeric item or between two numeric items will stop output without printing the second item.

If a comma or a semicolon is at the end of the output-list, the next PRINT statement begins printing on the same line, and spaced accordingly. If no punctuation finishes the list, a carriage-return and a line-feed are printed at the end of the data. The next PRINT statement will begin on the next line. If your output is directed to the screen and the data printed is longer than 40 columns, the output is continued on the next screen line.

There is no statement in BASIC with more variety than the PRINT statement. There are so many symbols, functions, and parameters associated with this statement that it might almost be considered as a language of its own within BASIC; a language specially designed for writing on the screen.

EXAMPLES of PRINT Statement:

1)

5 X = 5
10 PRINT -5*X,X-5,X+5,X^5

-25 0 10 3125

2)

5 X=9
10 PRINT X;"SQUARED IS";X*X;"AND";
20 PRINT X "CUBED IS" X^3

9 SQUARED IS 81 AND 9 CUBED IS 729

3)

90 AA$="ALPHA":BB$="BAKER":CC$="CHARLIE":DD$="DOG":EE$="ECHO"
100 PRINT AA$BB$;CC$ DD$,EE$

ALPHABAKERCHARLIEDOG ECHO

Quote Mode

Once the quote mark <SHIFT+2> is typed, the cursor controls stop operating and start displaying reversed characters which actually stand for the cursor control you are hitting. This allows you to program these cursor controls, because once the text inside the quotes is PRINTed they perform their functions. The <INST/DEL> key is the only cursor control not affected by "quote mode."

1. Cursor Movement
The cursor controls which can be "programmed" in quote mode are:

Function

KEY

APPEARS AS

Move Cursor Home

<CLR/HOME>

Clear Screen

<SHIFT+CLR/HOME>

Move Cursor Down

<CRSR UP/DOWN>

Move Cursor Up

<SHIFT+CRSR UP/DOWN>

Move Cursor Right

<CRSR LEFT/RIGHT>

Move Cursor Left

<SHIFT+CRSR LEFT/RIGHT>

If you wanted the word HELLO to PRINT diagonally from the upper left corner of the screen, you would type:
PRINT"<HOME>H<DOWN>E<DOWN>L<DOWN>L<DOWN>O"

2. Reverse Characters
Holding down the <CTRL> key and hitting <9> will cause <R> to appear inside the quotes. This will make all characters start printing in reverse video (like a negative of a picture). To end the reverse printing hit <CTRL+0>, or else PRINT a <RETURN> (CHR$(13)). (Just ending the PRINT statement without a semicolon or comma will take care of this.)

3. Color Controls
Holding down the <CTRL> key or <C=> key with any of the 8 color keys will make a special reversed character appear in the quotes. When the character is PRINTed, then the color change will occur.

COLOR

KEY

APPEARS AS

Black

<CTRL+1>

White

<CTRL+2>

Red

<CTRL+3>

Cyan

<CTRL+4>

Purple

<CTRL+5>

Green

<CTRL+6>

Blue

<CTRL+7>

Yellow

<CTRL+8>

Orange

<C=+1>

Brown

<C=+2>

Light Red

<C=+3>

Grey 1

<C=+4>

Grey 2

<C=+5>

Light Green

<C=+6>

Light Blue

<C=+7>

Grey 3

<C=+8>

If you wanted to PRINT the word HELLO in cyan and the word THERE in white, type:
PRINT "<CTRL+4>HELLO <CTRL+2>THERE"

4. Insert Mode
The spaces created by using the <INST/DEL> key have some of the same characteristics as quote mode. The cursor controls and color controls show up as reversed characters. The only difference is in the <INST> and <DEL>, which performs its normal function even in quote mode, now creates the <T>. And <INST>, which created a special character in quote mode, inserts spaces normally.

Because of this, it is possible to create a PRINT statement containing DELetes, which cannot be PRINTed in quote mode. Here is an example of how this is done:

10 PRINT"HELLO"<DEL><INST><INST><DEL><DEL>P"

When the above line is RUN, the word displayed will be HELP, because the last two letters are deleted and the P is put in their place.

WARNING: The DELetes will work when LISTing as well as PRINTing, so editing a line with these characters will be difficult.

The "insert mode" condition is ended when the <RETURN> (or <SHIFT+RETURN>) key is hit, or when as many characters have been typed as spaces were inserted.

5. Other Special Characters
There are some other characters that can be PRINTed for special functions, although they are not easily available from the keyboard. In order to get these into quotes, you must leave empty spaces for them in the line, hit <RETURN> or <SHIFT+RETURN>, and go back to the spaces with the cursor controls. Now you must hit <RVS ON>, to start typing reversed characters, and type the keys shown below:

Function

Type Appears As

<SHIFT+RETURN>

<SHIFT+M>  

switch to lower case

<N>  

switch to upper case

<SHIFT+N>  

disable case-switching keys

<H>  

enable case-switching keys

<I>  

The <SHIFT+RETURN> will work in the LISTing as well as PRINTing, so editing will be almost impossible if this character is used. The LISTing will also look very strange.


Commodore Cheetah made by Allen Monks, started in the year 2000.