Skip to content

printlib

Print and NPrint write values of any type to the current output: the console window of a program run from the editor or the Shell, or whatever a program has chosen as its output, such as a window or a file. Str$ gives the same text as a string instead of printing it.

How numbers look:

  • Bytes, words and longs are printed in decimal, with a - for negative values.
  • Quick values are printed rounded to four decimals; trailing zeros are left out, and so is a 0 before the point (.5). A value that rounds to a whole number is printed without a point (3).
  • Floats are printed with seven significant digits. FloatMode decides between the fixed point form and the exponent form (1.234567E+7).
  • With a format string set by Format, all numbers are printed in that format instead.

A format string describes each position: # is a digit or a space, 0 a digit or a zero, . the decimal point, - a minus sign for negative numbers or a space, + a plus or minus sign, and , a comma (a space where the number has no digits yet). Every other character is printed as it is. A number is rounded at the last place of the format; one with more digits before the point than the format has places gives a ? followed by its lowest digits (1234 with "##" prints ?34).

Library number 187.

Commands

FloatMode

How floats are printed: 1 always in exponent form, -1 always in fixed point form, 0 (the start value) in fixed point form for values from 1E-9 to below 1E+7 and in exponent form otherwise.

Statement. Help text: Mode : -1=standard, 0=guess, 1=exp
Arguments: .w

Format

Sets the format string for numbers printed by Print, NPrint and Str$; an empty string switches it off. With a format, floats are always printed in fixed point form.

Statement. Help text: FormatString
Arguments: $

The format string may have at most 32 characters; with runtime error checking, a longer one is the error “Format String too long”.

A number is rounded at the last place of the format. When the format has no - or +, a negative number gets its minus sign in front of its first digit, also in front of the zeros of 0 places: -7 with "000" prints -07.

NPrint

Writes the values like Print and then a line end.

Statement. Help text: Expression[,Expression...]
Arguments: { any }...

Print

Writes the values, one after the other without separators, to the current output; the cursor stays behind the last one.

Statement. Help text: Expression[,Expression...]
Arguments: { any }...

Str$

The value as Print would write it, as a string; a format set with Format applies. Str$ of a string gives the string itself.

Function, result $. Help text: (Expression)
Arguments: any

UStr$

Like Str$, but always without the format set by Format.

Function, result $. Help text: (Expression)
Arguments: any