The format consists of string format fields, numeric format fields and ordinary characters. The format is scanned repeatedly, processing each value in the list in turn. When a string format field is encountered, a value expected to be a string is taken from the list, formatted and written. When a numeric format field is encountered a value expected to be numeric is taken from the list, formatted and written. When an ordinary character is encountered, it is written without processing with the exception of a force character, _ (underscore) followed by any character, which forces the following character to be written without interpretation.
The format is scanned repeatedly until the list of values is exhausted. If no values are present, nothing is done. If the list of values is satisfied part way through a scanning of the format, ordinary characters are interpreted until a format field appears or the end of the format is encountered.
The string format fields are three. The character & (ampersand) formats a string without modification. The character ! (exclamation) or a pair of \ (backslash) characters separated by zero or more blanks format a string field with a width equal to that of the format field; the string text is left-justified within the field and padded with blanks if necessary.
The numeric fields are defined as follows: an unsigned field may be preceded by + (plus) or succeeded by + (plus) or - (minus). An unsigned field consists of an optional prefix followed by a digit field followed by an optional exponent field. The prefixes are $$, ** and **$. The exponent field is ^^^^ (four carets). The digit field is a series of # (pound) characters which may contain one decimal point and/or zero or more commas; a comma may not be the first character of the digit field.
A numeric value is formatted justified about the decimal point or the end of the digit field if no decimal point was specified. For a format without an exponential field, the non-fractional part of the value is formatted to the left of this location (including commas every third digit if a comma was included in the digit field) preceded by the sign (if the leading + (plus) was specified or if the value is negative and no sign format was specified) preceded by a $ (dollar) (if either of the prefixes $$ or **$ was specified). If there is any space remaining in the left part of the field, it is padded with * (asterisk) characters if either of the prefixes ** or **$ was specified. Formats with an exponential field are similar except that (for non-zero values) padding is avoided: instead the digit field is expanded (and the exponent is adjusted accordingly). A minimum amount of space is required to format at least one digit in the number, a sign and a $ (dollar) sign.
If a decimal point was specified, the fractional part of the number is formatted to the right (filled with zeroes if necessary) followed by an exponent of the form E±dd or D±dd for double-precision values (if an exponent field was specified) followed by the sign (if a trailing sign was specified) or a blank (if the value is non-negative and a trailing - (minus) was specified).
The force character _ (underscore) when followed by a character causes that character to be written without interpretation.
This function implements the LPRINT USING, PRINT USING and PRINT USING # statements.
Error 13 (Type mismath) is generated if a value is numeric and a string field is encountered in the format or vice versa.
A % (percent) character is printed before a number if the field specified is too narrow to represent the value.
from The Basmark QuickBASIC Programmers Manual by Lawrence Leinweber