Commands and Statements |
The PRINT statement returns the value of expressions or the text of strings to the console, or to any
You can print data to any
PRINT [II filenumber,][[ expression], I;]...
10 INPUT "A string"; X$
20PRINT "YOUR STRING IS ";X$
30END
RUN
?A string
YOUR STRING IS A string
Ok
PRINT USING
The PRINT USING statement specifies particular formats to print strings or numbers. The format string may include more than one field, and may also include any literal character that is not a PRINT USING formatting character. The syntactic format of PRINT USING is:
PRINT [# file number,] USING format string; expression [, expression] ...
in which the format string specifies spacing and additional characters (such as asterisks and dollar signs) when used with numeric fields, and which specify portions of the given string when used with string fields. Each expression is printed with the same format. The optional file number specifies the number of an open file. See Chapter 5 for details of sequential disk file 110.
String Fields
There are two formatting choices when using PRINT USING with string fields:
"!" specifies that the first character of each specified string is printed.
"\ n spaces \" specifies that the first 2+N characters are printed. If the backslashes are used without spaces, two characters are printed.
If the string field has more characters than the format string, the balance are ignored; if there are fewer characters than specified, spaces are printed to fill out the field. Here are examples of the string field formats:
10X$="ONE"
20Y$="TWO"
30PRINT USING "!"; X$; Y$
40PRINT USING" \ \"; X$; Y$
RUN OT
ONE TWO Ok