BASIC IO functions

From DenialWIKI
Jump to navigation Jump to search

SAVE

SYS57809(N$),<device>:POKE193,<start_lo>:POKE194,<start_hi>
POKE780,193:POKE781,<end_lo>:POKE782,<end_hi>:SYS65496
SYS57809(N$),<device>,1:POKE193,<start_lo>:POKE194,<start_hi>
POKE780,193:POKE781,<end_lo>:POKE782,<end_hi>:SYS65496

LOAD

SYS57809(N$),<device>:POKE780,0:POKE781,<start_lo>:POKE782,<start_hi>:SYS65493
SYS57809(N$),<device>,1:POKE780,0:SYS65493

OPEN

CLOSE

PRINT

PRINT is the most versatile instruction in CBM BASIC. It provides the display of constant strings, numbers, numeric expressions, and string expressions; added to this are simple means to format the output.

A constant string is written in quotes, and displayed thus:

PRINT "HELLO VIC!"
HELLO VIC!
READY.

A number isn't embedded in quotes:

PRINT 1
 1

When printing numbers, a space is printed to the left of the number, when that number is positive. With a negative number, the minus sign is printed instead of the space.

PRINT -2
-2

The PRINT statement allows for a quick calculation of numeric expressions on the READY prompt:

PRINT 2+3*5
 17

Finally, string expressions are also allowed:

10 N$="-20"
20 PRINT "VIC"+N$
RUN
VIC-20

All these formats can be combined within one PRINT statement, as long as the maximum line length (88 characters) isn't exceeded. Normally, a PRINT statement adds an implicit carriage return (CR) at the line, moving the cursor to the beginning of the next line. A semicolon at the end of the argument suppresses that CR. The semicolon also is often used, though not mandantory, to concatenate the output of two arguments.

A comma between two arguments aligns to the next tabulator. This is either the middle of the current line, or the begin of the next line.

PRINT#

PRINT# works like PRINT, expect its first argument refers to a logical file number from an OPEN statement.

It is used to write data to files to tape, or floppy disc; or to send commands to the floppy drive.

INPUT

INPUT#

GET

GET#

CMD

ST