Home Page

BASIC Handbook

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


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

My BASIC Quick Reference Guide

Abbreviation: P <SHIFT+R>

TYPE: I/O Statement
FORMAT: PRINT#<file-number>[<variable>][<,/;><variable>]...

Actions: The PRINT# statement is used to write data items to a logical file. It must use the same number used to OPEN the file. Output goes to the device-number used in the OPEN statement. The <variable> expressions in the output-list can be of any type. The punctuation characters between items are the same as with the PRINT statement and they can be used in the same ways. The effects of punctuation are different in two significant respects.

When PRINT# is used with tape files, the comma, instead of spacing by print zones, has the same effect as a semicolon. Therefore, whether blanks, commas, semicolons or no punctuation characters are used between data items, the effect on spacing is the same. The data items are written as a continuous stream of characters. Numeric items are followed by a space and, if positive, are preceded by a space.

If no punctuation finishes the list, a carriage-return and a line-feed are written at the end of the data. If a comma or semicolon terminates the output-list, the carriage-return and line-feed are suppressed. Re-gardless of the punctuation, the next PRINT# statement begins output in the next available character position. The line-feed will act as a stop when using the INPUT# statement, leaving an empty variable when the next INPUT# is executed. The line-feed can be suppressed or compensated for as shown in the examples below.

The easiest way to write more than one variable to a file on tape or disk is to set a string variable to CHR$(13), and use that string in between all the other variables when writing the file.

EXAMPLES of PRINT# Statement:

1) 10 OPEN 1,1,1,"TAPE FILE"
20 R$=CHR$(13)
30 PRINT#1,1;R$;2;R$;3;R$;4;R$;5
40 PRINT#1,6
50 PRINT# 1,7

(By Changing the CHR$(13) to CHR$(44) you put a "," between each variable. CHR$(59) would put a ";" between each variable.)
2) 10 CO$=CHR$(44):CR$=CHR$(13)
30 INPUT#1,A$,BCDE$,F$

AAA,BBB CCCDDDEEE (carriage return) FFF(carriage return)
3) 5 CR$=CHR$(13)
10 PRINT#2,"AAA";CR$;"BBB"
20 PRINT#2,"CCC";
30 INPUT#2,A$,B$,DUMMY$,C$

(10 blanks) AAA BBB
(10 blanks)CCC

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