Table of Contents

PRINT USING

A special version of the PRINT statement for formatted strings output to screen

Implemented by: dartmouth6, ansifull, hptsb, decbasic, altair12K, Applesoft, cbmv7, cbmv3.5, ataplus, atxl, msatari, level2, MSX, bwbasic, bw32, ABasiC, msamiga, QBasic, FreeBASIC

With variations:

Also written as:

Usage

PRINT USING allows the use of a "format string" as a template or "mask" for screen output of variables, specially numeric ones. This string is the first argument taken by the statement:

PRINT USING "**####.##";1.2345

In most Microsoft-based BASICs, a semicolon (;) after the format string makes the output to happen where the text cursor is, and a comma (,) will place the output in the next "tab column" (which varies among platforms). Then follows the value(s) or variable(s) whose content is to be formatted — commas are used to separate them.

Most characters in the format string are printed literally, except the following ones, which acquire special meanings and effects:

PRINT USING "#.##^^^^"; 1.234567
0.12E+01
 
PRINT USING "###^^^^"; 1.234567
123E-02
 
PRINT USING "###^^^^"; 1.2345678
123D-02

For string values, there is a smaller number of options (and their usefulness is not exactly clear):

PRINT USING "!"; "JOHN"
J
 
PRINT USING "!!!!"; "JOHN", "PAUL", "GEORGE", "RINGO"
JPGR
PRINT USING "\\"; "JOHN", "PAUL", "GEORGE", "RINGO"
JOPAGERI
 
PRINT USING "\ \"; "JOHN", "PAUL", "GEORGE", "RINGO"
JOHPAUGEORIN

Variations

The 1972 manual of DEC BASIC-PLUS states that, unlike regular PRINT, using a trailing colon after PRINT will have no effect with PRINT USING. A trailing semicolon will however avoid a line break after the output.

In MS-QuickBASIC and QBASIC, only a semicolon can be used between the format string and the values list.

PRINT USING clearly had no consideration for locale, right-to-left languages and such.

Examples

Comments

The implementation of PRINT USING by Altair 12kB version is pretty much similar to the one of DEC BASIC-PLUS. As such it descended to other various 8-bit BASICs. Apparently, Apple and Commodore refused to pay any extra for PRINT USING. The statement was not implemented in the Sinclair family as well.

Similar keywords

In other languages...

PRINT USING is rather unique in the style of format strings it uses. In contrast, the loosely similar and contemporary C printf() function established a more versatile, more powerful and by large ubiquitous standard for formatted text output.

References