PRINT# - DualBrain/bsharp GitHub Wiki

To write data to a sequential disk file.

Syntax

PRINT#file number,[USINGstring expressions;]list of expressions

Comments

file number is the number used when the file was opened for output.

string expressions consists of the formatting characters described in the PRINT USING statement.

list of expressions consists of the numeric and/or string expressions to be written to the file.

Double quotation marks are used as delimiters for numeric and/or string expressions. The first double quotation mark opens the line for input; the second double quotation mark closes it.

If numeric or string expressions are to be printed as they are input, they must be surrounded by double quotation marks. If the double quotation marks are omitted, the value assigned to the numeric or string expression is printed. If no value has been assigned, 0 is assumed. The double quotation marks do not appear on the screen. For example:

10 PRINT#1, A
 0
10 A=26
20 PRINT#1, A
 26
10 A=26
20 PRINT#1, "A"
 A

If double quotation marks are required within a string, use CHR$(34)(the ASCII character for double quotation marks). For example:

100 PRINT#1,"He said,"Hello", I think"
 He said, 0, I think
text

because the machine assigns the value 0 the variable "Hello."

```text
100 PRINT#1, "He said, "CHR$(34) "Hello,"CHR$(34) " I think."
 He said, "Hello," I think

If the strings contain commas, semicolons, or significant leading blanks, surround them with double quotation marks. The following example will input "CAMERA" to A$, and "AUTOMATIC 93604-1" to B$:

10 A$="CAMERA, AUTOMATIC": B$="93604-1"
20 PRINT#1, A$; B$
30 INPUT#1, A$, B$

To separate these strings properly, write successive double quotation marks using CHR$(34). For example:

40 PRINT#1,CHR$(34); A$; CHR$(34); CHR$(34); B$; CHR$(34) "CAMERA,AUTOMATIC""93604-1"

The PRINT# statement may also be used with the USING option to control the format of the disk file. For example:

PRINT#1, USING"$$###.##."; J; K; L

PRINT# does not compress data on the diskette. An image of the data is written to the diskette, just as it would be displayed on the terminal screen with a PRINT statement. For this reason, be sure to delimit the data on the diskette so that it is input correctly from the diskette.

In list of expressions, numeric expressions must be delimited by semicolons. For example:

PRINT#1, A; B; C; X; Y; Z

If commas are used as delimiters, the extra blanks inserted between print fields will also be written to the diskette. Commas have no effect, however, if used with the exponential format.

String expressions must be separated by semicolons in the list. To format the string expressions correctly on the diskette, use explicit delimiters in list of expressions. For example, the following:

10 A$="CAMERA": B$="93604-1"
20 PRINT#1, A$, B$

gives a diskette image of:

CAMERA93604-1

Because there are no delimiters, this would not be input as two separate strings. To correct the problem, insert explicit delimiters into the PRINT# statement as follows:

30 PRINT#1, A$; ","; B$

This gives the following diskette image, which can be read back into two string variables:

CAMERA, 93604-1