Commodore 128 Programmer's Reference Manual page 390

Hide thumbs Also See for 128:
Table of Contents

Advertisement

380
COMMODORE 128
PRINTING A TYPED LINE
-
A PRINT# command to an opened print file number outputs the associated data to the
\ j
printer. The following commands output whatever is typed:
Jj
OPEN3,4:PRINT#3,"TYPE ANYTHING"
After RETURN is depressed, the line is sent to the printer and anything
J j
under quotes is printed on paper.
^
PRINTING THROUGH A PROGRAM
)J
Instructions to a printer require a PRINT# statement and can be mixed with the
PRINT statement for video display. The following program prints five lines of text for
. ■ >
each PRINT# statement while using the screen display to obtain the input:
f
10
20
25
30
40
50
60
70
OPEN 3,4,7
DO UNTIL L = 5
IF L=0THEN30 :ELSE INPUTA$:GOTO40
INPUT'TLEASE TYPE";A$
PRINT#3,A$
L=L+1
LOOP
CLOSE3
This is the beginning of a simple word processor and could be expanded into a
complex system through printer control.
CONTROLLING YOUR PRINTER
Each printer capability (such as lower case characters, line feed, double width charac
ters, reverse characters, dot graphics and special print fonts) is controlled by sending the
proper control code from the computer. Depending upon the printer being used, there
are two ways of sending code—either via the CHR$ function or the secondary address.
Standard codes are sent via the BASIC CHR$(X) function. ASCII codes under 27
are generally reserved for printer codes (such as 14 for the double width feature). Codes
over 27 represent specific keyboard characters. Printer control codes over 27 (e.g., 145)
are preceded with the ESCape code 27. Some systems will accept CHR$(27) followed
by either CHR$(X) or the equivalent character within quotes. Thus, boldface type
represented by Code 33 could be turned on with:
PRINT#3, CHR$(27)CHR$(33)
or
PRINT#3, CHR$(27)"!"
and turned off with:
PRJNT#3, CHR$ (27)CHR$(34)
assuming channel 3 was previously opened.
u

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents