NAME

print using - formatted print

SYNOPSIS

print using StrExpr; ExprList[;]

DESCRIPTION

Print using prints the values indicated in its ExprList according to the formatting information given in the string expression StrExpr.  This formatting information (see below) determines the field and the format of the printed strings and numbers.  ExprList consists of the string expressions or numeric expressions whose values are to be printed, separated by semicolons or commas. 

If a number to be printed is larger than the specified numeric field, a percent sign (%) is printed in front of the number.  If rounding causes the number to exceed the field, the percent sign is printed in front of the rounded number.  See lines 20 and 21 in the example given below. 

String Fields

One of three formatting characters may be used to format the string field. 

!
The exclamation point specifies that only the first character in the given string is to be printed. 

\\
If the backslashes are typed with no spaces between them, two characters are printed.  For each space between the backslashes, an additional character is printed.  If the string is longer than the field, the extra characters are ignored.  If the field is longer than the string, the string is left-justified in the field and padded with spaces on the right.  See lines 1 through 3 in the examples below. 

&
Specifies a variable length string field.  When used, the string is output exactly as input.  See lines 4 and 5 in the examples below. 

Numeric Fields

The following special characters may be used to format the numeric field:

#
Each number sign represents a single digit position.  Digit positions are always filled.  If the number to be printed has fewer digits than positions specified, the number is right-justified in the field and padded with spaces to the left. 

A decimal point may occur anywhere in the field.  If the format string specifies that a digit precedes the decimal point, the digit will be printed (as 0 if necessary).  Rounding occurs as necessary.  See lines 6 through 8 in the examples below. 

+
A plus sign at the beginning or end of the format string causes the sign of the number (plus or minus) to be printed before or after the number respectively. 

-
A minus sign at the end of the format field causes negative numbers to be printed with a minus sign at the end.  The plus and minus signs are mutually exclusive; i.e., they cannot appear together in a format description.  See lines 9 and 10 in the examples below. 

**
A double asterisk at the beginning of the format string fills leading spaces in the numeric field with asterisks; it also specifies positions for two more digits.  See line 11 in the examples below. 

$$
A double dollar sign causes a leading dollar sign to be printed.  It also specifies two more digit positions, one of which is the dollar sign.  The exponential format may not be used.  Negative numbers may be used if the minus sign trails to the right.  See line 12 in the examples below. 

**$
The **$ at the beginning of a format string causes leading spaces to be filled with asterisks and a dollar sign to be printed before the number.  It also specifies three more digit positions, one of which is the dollar sign.  See line 13 in the examples below. 

The **, $$, and **$ are mutually exclusive; i.e., they may not appear together in a single format description. 

,
A comma to the left of the decimal point in a formatting string causes a comma to be printed to the left of every third digit to the left of the decimal point.  A comma at the end of the format string is printed as part of the string.  A comma specifies another digit position.  The comma has no effect if used with the exponential (^^^^) format.  See lines 14 and 15 in the examples below. 

^^^^
Four carets placed after the digit position characters specify exponential format.  The four carets allow space for E+-nn or D+-nn to be printed.  Any position may be specified for the decimal point.  The significant digits are left-justified, and the exponent is adjusted accordingly.  One digit position is used to the left of the decimal point to print a space or a minus sign unless a leading + or trailing + or - is specified.  See lines 16 through 18 in the examples below. 

Force Character

_
An underscore in the format string causes the next character to be output as a literal character.  The literal character itself may be an underscore by placing "__" (two underscores) in the format string.  See line 19 in the examples below. 

EXAMPLE

The following program illustrates the various formats for print using. 
	   a$ = "SANTA": b$ = "CLAUS"
	 1 print using "!"; a$; b$
	 2 print using "\\"; a$; b$
	 3 print using "\ \"; a$; b$
	 4 print using "!"; a$;
	 5 print using "&"; b$
	 6 print using "##.##"; .69
	 7 print using "###.##"; 562.206
	 8 print using "##.##   "; 15.4, 4.1, 84.035, .381
	 9 print using "+##.##   "; -52.69, 1.4, 26.6, -.7
	10 print using "##.##-   "; -52.69, 23.361, -3.02
	11 print using "**#.# "; 35.04, -0.7, 953.2
	12 print using "$$###.##"; 132.05
	13 print using "**$##.##"; 6.09
	14 print using "####,.##"; 2405.39
	15 print using "####.##,"; 2405.39
	16 print using "##.##^^^^"; 815.03
	17 print using ".###^^^^-"; -66666
	18 print using "+.##^^^^"; 512
	19 print using "_!##.##_!"; 32.87
	20 print using "##.##"; 653.98
	21 print using ".##"; .999
This produces the output
	SC
	SACL
	SA CL
	SCLAUS
	 0.69
	562.21
	15.40    4.10   84.03    0.38   
	-52.69    +1.40   +26.60    -0.70   
	52.69-   23.36     3.02-   
	*35.0 *-0.7 953.2 
	 $132.05
	***$6.09
	2,405.39
	%2,405.390
	 8.15E+02
	.667E+05-
	+.51E+03
	!32.87!
	%653.98
	%1.00

SEE ALSO

print

DIAGNOSTICS

If the number of digits specified in StrExpr exceeds 24, an "Illegal function call" error occurs. 

If an item in ExprList does not have a type appropriate for its field in StrExpr, a "Type mismatch" error occurs. 

from The Basmark QuickBASIC Programmerís Manual by Lawrence Leinweber