PRINT statement

Purpose

Write data to the current console text page (screen) at the current caret location.

Syntax

PRINT [ExpList] [SPC(n)] [TAB(n)] [,] [;] [...]

Remarks

The PRINT statement has the following parts, which may occur in any order, and quantity within a single PRINT statement:

ExpList

Numeric and/or string expression(s) to be written to the console.

SPC(n)

An optional function used to insert n spaces into the printed output.  Multiple use of the SPC argument is permitted in the PRINT statement, for example, between expressions.  Values of n less than 1 are ignored.

TAB(n)

An optional function used to tab to the nth column before printing ExpList.  Multiple use of the TAB argument is permitted in the PRINT, for example, to position arguments in columns.  Values of n less than 1 are ignored.

{;|,}

Character that determines the position of the next character printed.  A semicolon (;) means the next character is printed immediately after the last character; a comma (,) means the next character is printed at the start of the next print zone.  Print zones begin every 14 columns.

If the final argument of a PRINT statement is a semicolon or comma, the caret position is maintained at the current location, rather than the default action of scrolling the print position to the start of the next line.  For example:

PRINT "Hello";

PRINT " world!";

...produces the contiguous result "Hello world!"

If you omit all arguments, the PRINT statement prints a blank line.  Printing always begins at the current caret position.  Output of the PRINT statement cannot be redirected to a file or device, it always goes to the current active console screen.  For redirectable output, use the STDOUT statement.

Any control codes such as Carriage Return, Line-Feed and Backspace are not interpreted by PRINT and will display on the screen as symbols in the current selected font.

A question mark may be used as an abbreviation for the PRINT statement.

PRINT USING$ is not one statement in PBCC as it was in DOS. USING$ is a seperate function, see the USING$ function for more information.

Restrictions

Printing a User-Defined Type (UDT) variable is allowed, but the UDT is treated as if is a fixed-length string.  Therefore, if the UDT contains non-string data types or padding due to member alignment, the displayed byte-for-byte ASCII/ANSI representation of the bytes that comprise the non-string positions may appear as blocks of "garbage" characters.

It is not possible to directly PRINT a Variant, Object Variable, or an entire array (i.e., PRINT MyArr#()).  For arrays, use a FOR/NEXT loop to iterate through the individual elements.  In the case of Variants, they should first be translated to the intended data type with the VARIANT# or VARIANT$ function.  For example:

DIM x AS VARIANT

x = 1

PRINT VARIANT#(x)

See also

CLS, COLOR, LINE INPUT, LOCATE, PAGE, PAGEACTIVE, PAGEVISIBLE, PCOPY, STDOUT, USING$

Example

PRINT TAB(10) "This is a test, this is only a test..."

PRINT a$; b$; SPC(2); d$; x&, y&;

? TAB(10) a$ "1" b$ "2",,,