ConPrint command



ConPrint StringExpr


Legacy Syntax:

PRINT [ExprList]


Pseudo-object Syntax:

CON.PRINT [ExprList]


Writes text data to the active console page buffer (screen).


The output always goes to the currently active console screen starting at the current cursor position and using the current color attributes.


For redirectable output, use StdOutPrint or StdErrPrint instead.




ConPrint can be used only to output a single string expression. ConPrint cannot have a trailing ";" to suppress CR+LF like the PB/CC PRINT statement, so it defaults to no CR+LF output. If a CR+LF is required it must be explicitly specified at the end of the string expression. For example:


#IF %DEF(%PB_CC32)

  PRINT "Hello World"


  ConPrint "Hello World" + $CRLF



A question mark cannot be used as a substitute for ConPrint as in PB/CC (in PB/Win, a question mark is a substitute for MSGBOX).


The PB/CC PRINT statement can only be partially emulated with a simple externally programmed procedure because its parameters are of variable number and type, and the separators used between items is significant in formatting the output. It is not a straightforward command, but a deeply embedded compiler statement (it is one of the oldest BASIC statements, dating back to Dartmouth BASIC in the 1960s).


In PB/CC, ExprList is a variable number of numeric or string expressions separated by commas (,) or semicolons (;). A semicolon (;) means the next item is printed immediately after the last item; a comma (,) means the next item is printed at the next multiple of 14 columns. If the ExprList is terminated by a semicolon or a comma, the print position stays on the current line, rather than the default action of leaving the print position at the start of the next line. Special items which may be included in the ExprList are SPC(n), where n is a number of spaces to include in the output, and TAB(n), where n is a column number.


To emulate this behavior using ConPrint, it is necessary to do one or more of the following:


(a) Add $CRLF to all PRINT statements that do not end with a comma or semicolon.

(b) Split PRINT statements containing comma separators or TAB(n) functions.

(c) Convert the ExprList into a single string expression.


(a) As noted above, ConPrint does not output a CR and LF after printing. This means that the documented behavior of PB/CC PRINT of displaying printable characters for all control codes is not true of ConPrint. It also means that the StringExpr parameter is not optional (there would be no point) and ConPrint with a null string does not terminate a line or produce a blank line, as in PB/CC.


(b) The only way to produce tabulated output with ConPrint is by use of separate ConPrint commands separated by ConTab commands. For example:


#IF %DEF(%PB_CC32)

  PRINT "Column 1", "Column 2",


  ConPrint "Column 1": ConTab: ConPrint "Column 2": ConTab





#IF %DEF(%PB_CC32)

  PRINT "Unit price:";TAB(20);Value!


  ConPrint "Unit price:": ConTab(20): ConPrint STR$(Value!) & $CRLF



(c) It is relatively easy to convert the ExprList into a string expression after the tabs have been taken care of, as above. Convert numeric variables and expressions into STR$ function calls. Replace SPC(n) with SPACE$(n). Replace ";" separators with "&" or "+" string concatenation operators. Thus:


#IF %DEF(%PB_CC32)

  PRINT "Total:";Total!


  ConPrint "Total:" & STR$(Total!) & $CRLF



Fortunately, USING$ is implemented as a separate function in PowerBASIC and it's also included in PB/Win. Any USING$ expression can be passed to ConPrint as is (as can any FORMAT$ expression). See the PB help file or manual for details.


CON.PRINT or CONSOLE.PRINT may be substituted for PRINT in programs written for PB/CC6.


See also: StdOutPrint, StdErrPrint, ConTab