HTBasic Help
×
Menu
Index

PRINT

Outputs data to the PRINTER IS device.
 
 PRINT [items [{,|;}]]
 PRINT USING image [;items]
 
Usage:
PRINT "Test Number ";N;
PRINT Values(*)
PRINT String$[1,8],TAB(12),Result
PRINT TABXY(1,1),Title$,TABXY(Col,3),Par$
PRINT USING 1040;R1,R2,R3
PRINT USING Fmt;Ssn,Item$,Weight
 
Example:           PRINT.BAS
 
Description:
PRINT sends numeric data, array elements or character strings to the PRINTER IS device. The default PRINTER IS device is the CRT. The output may optionally be formatted with the USING image.
 
Unless USING is specified, numeric items are printed in standard numeric format. If the absolute value is in the range 1E-4 to 1E+6, it is rounded to twelve digits and printed in floating point form. Otherwise the number is printed in scientific notation.
 
If USING is not specified, then the punctuation following the item determines the item's print field width and suppresses the automatic EOL sequence. The compact field is used if a semicolon follows the item; and the default print field is used if a comma follows the item.
 
In both compact and default print form, numeric numbers are printed with one leading blank for positive numbers or the minus sign for negative numbers. In compact field form numeric items are printed with one trailing blank and string items are printed with no leading or trailing blanks. The default print field form prints items with trailing blanks to fill to the beginning of the next ten character field.
 
A complex number is printed in rectangular form, first the real part, then an extra space and finally the imaginary part.
 

Arrays

A full array may be printed in row-major order using the full array specifier, "(*)". If a semi-colon follows an array then the array elements are printed in compact fields. If a comma follows an array then default print fields are used. Additionally the automatic EOL sequence will be suppressed if either a semi-colon or a comma is used.
 

TAB/TABXY

The TAB function positions the next print character on the print line using the following equation: TAB column_position = ((column - 1) MOD screenwidth) + 1. The TABXY function positions the next print character on the CRT with X (column) and Y (row) coordinates. TABXY(1,1) specifies the upper-left of the CRT. A zero value for either argument specifies the current value for that argument.
 
If the CRT is not the PRINTER IS device, TABXY is ignored. TAB and TABXY can not be used with USING.
 

End-Of-Line

At the end of the list of items to PRINT, an EOL is sent to the PRINTER IS device. This can be suppressed by using trailing punctuation. EOL is also sent when the print position reaches the WIDTH  of the printer. WIDTH and the EOL characters can be defined with the PRINTER IS command. The default WIDTH is the width of the screen or window, and the default EOL is CR/LF (CHR$(13) & CHR$(10)).
 

Control Characters

The following control characters have a special meaning when used in PRINT statements when the CRT is the PRINTER IS device:
 
Character            Meaning
CHR$(7)                  Ring the bell.
CHR$(8)                  Moves print cursor back one space.
CHR$(10)                Moves print cursor down one line.
CHR$(12)                Prints two line-feeds, scrolls output area buffer so next item goes to the top of the CRT.
CHR$(13)                Moves print cursor to column one.
Character              Meaning
CHR$(128)                All enhancements off.
CHR$(129)                Inverse mode on.
CHR$(130)                Blinking mode on.
CHR$(131)                Inverse and Blinking modes on.
CHR$(132)                Underline mode on.
CHR$(133)                Underline and Inverse modes on.
CHR$(134)                Underline and Blinking modes on.
CHR$(135)                Underline, Inverse, & Blinking modes on.
Character              Meaning
CHR$(136)                White
CHR$(137)                Red
CHR$(138)                Yellow
CHR$(139)                Green
CHR$(140)                Cyan
CHR$(141)                Blue
CHR$(142)                Magenta
CHR$(143)                Black
 
All other characters less than CHR$(32) are ignored. To print, rather than ignore, the characters in this range, use DISPLAY FUNCTIONS.
 
If some characters don't display correctly when you use the PRINT or LIST commands, it may be caused by conflicts with the attribute control characters in the range of 128 to 143. To move the attribute control characters from the range 128 to 143 down to the range 16 to 31, use the following command:
 
CONTROL CRT,100;1
 

With USING

See IMAGE for a complete explanation of the image list. The items specified in the image list are acted upon as they are encountered. Each image list item should have a matching print item. Processing of the image list stops when no matching print item is found. Conversely, the image list is reused starting at the beginning to provide matches for all remaining print items. FORMAT ON is used in connection with PRINT USING, even if FORMAT OFF has been specified.
 
Back-porting
to HP BASIC:
CONTROL CRT, 100 is a new HTBasic feature that is not available in HP BASIC. It should not be used in programs that must be ported back to HP BASIC.
 
See Also: