'Welcome to the Commodore Computer Wiki!'

PRINT#

Keyword Token Version Category(s)
PRINT# $98 1.0 Command and Statement

Syntax

PRINT# file_num [ , [ , | ; | SPC(count) | TAB(column) ]… value [< , | ; | SPC(count) | TAB(column) > [value] ]… ]

Where file_num is the file number assigned to an open file.

Purpose

Print a numeric or string value to a logical file.

Notes

The keyword PRINT# may not be abbreviated with ”?#”. The correct abbreviation is P shift-R “pR”.

value may be a literal, variable, or an expression of either numeric or string type.

PRINT# 8, 1.5 :REM numeric literal
PRINT# 8, X   :REM numeric variable
PRINT# 8, 2*X :REM numeric expression
PRINT# 8, LEFT$(N$,12) :REM string expression
PRINT# 8, N$  :REM string variable
PRINT# 8, "HELLO" :REM string literal
PRINT# 8, SPC(8); "HELLO" :REM output 8 spaces before string

Multiple values may be sent to the logical file without any seperation between them (use semicolons) or by “spacing” between them (use commas). Multiple values may also be seperated with the SPC() and TAB() functions. After sending them to the file, BASIC will normally also send a final carriage return but this may be suppressed by ending the statment with a semicolon. See PRINT for details.

When two values are sperated with a comma, BASIC will print 12 spaces between the two values in the output file.

Although SPC() works fine, TAB() does not because BASIC has no idea of the “current column” in the output file.

If nothing follows file_num, then BASIC will just send a carriage return (character $0D = CHR$(13)).

Whenever BASIC sends a carriage return, it will also send a line feed (character $0A = CHR$(10)) immediately after it if file_num is 128 or greater.

See also OPEN, CMD, SPC(), TAB(), USING
Compare with PRINT
Contrast with INPUT#


This page is a member of Commodore BASIC