PRINTUSING
General Form:
Where:
The statement is used to print data in the specified format on the currently selected output device. If a stream number is specified then the ouput is written to the file currently open on the that stream.
The image specification defines the format of the output on the print line. The image specification may be specified by an alpha variable, by referencing the line number of an % (Image), or $IMAGE statement, or by specifying a literal string, for example:
Using a variable:
image$ = "####.###"
PRINTUSING image$, price
Using an % (Image) statement:
00100 % ####.###
00110 PRINTUSING 100, price
Using the $IMAGE statement (required for multi-language support):
00100 $IMAGE <<"£####.###", "####.###FF">>
00110 PRINTUSING 100, price
Using a literal string:
PRINTUSING "####.###", price
The image specification can contain one or more # characters to determine the location of a formatted variable. The following symbols may be included in the format specification: dollar sign '$', plus signs '+, ++', minus signs '-,--', and up arrows '^'. The integer portion of a numeric format may include commas ',' before the decimal point '.'. An image statement may also include other printable characters before and after the format specifications. If a colon is used within an image statement, it will be interpreted as part of the image and not a statement separator.
Numeric print elements
Numeric data can be formatted in either, integer format '###', fixed point format '###.###', or exponential format '##.#^^^^'. The image controls the formatted output of numeric values as follows:
Example:
price = 11123.46: quantity = 47
PRINTUSING 120, price, quantity
% -$###,###.## ###
$11,123.46 47
Alphanumeric print elements
Each image character is replaced by a character from the alpha value. The alpha character string is left justified in the format field. If the alpha string is larger than the image then the string is right truncated. If it is smaller it will be extended with trailing spaces.
Example:
price = 11123.46
quantity = 47
code$ = "ABCDEF"
PRINTUSING 120, price, quantity, code$
% -$###,###.## ###
######
$11,123.46 47 ABCDEF
Suppression of Carriage Returns
The carriage return character (HEX(0D)) is usually issued at the end of a print line when all print elements are satisfied or all image specifications have been used. The semi-colon can be used to replace the comma at the point where a carriage return would normally be issued, to separate each print element to suppress the printing of a carriage return. When execution of the PRINTUSING statement is complete, PRINTUSING usually generates a carriage return. This can also be suppressed by appending a semi-colon after the last print element.
Alternative currency support
The $CONVERT function is used to specify two currency names and a conversion rate to convert between them. The specified rate can then be used with PRINTUSING to allow reports to dynamically switch the value of currency fields. It is also used by multi-currency enabled forms to automatically convert form fields between two currencies
Currency fields are defined in PRINTUSING images by the use of the dollar ($) sign instead of the hash (#) symbol. However, to enable this feature you must set the HEX(10) bit of byte 47 in $OPTIONS RUN and change the default leading currency symbol specified in byte 4 of $OPTIONS to a hash symbol, e.g. STR($OPTIONS,4 ,1) = "#". For example:
STR($OPTIONS, 4, 1) = "#"
STR($OPTIONS RUN, 47, 1) = OR HEX(10)
$CONVERT = "GBP, EUR, 1.23"
PRINTUSING "-$$$$$.$$ -#####.##", 5, 5
would give the following output:
4.07 5.00
See $CONVERT for more information.
Syntax examples:
PRINTUSING "-######", temp
PRINTUSING 100, test$(5), price(4), qt
PRINTUSING images$, FLD(temp$.name$), qt
PRINTUSING #45, image$, info
PRINTUSING #10, 100, test1, name$
See also: