Each character in the IMAGE string has a special meaning. For example, the letter A means "an alphanumeric character must be printed here", the letter D means "a decimal numeric value must be printed here", and the letter X means "a space character must be printed here." The order in which data items are specified in the USING statement must match the IMAGE string. For Example:
100 PRINT USING 110;"Base Price:",6995
110 IMAGE 11A,X,4D
In this example, the print format is specified in the IMAGE statement in line 110. The IMAGE string 11A,X,4D defines two "print fields" or "print zones" separated by one extra space (X). The first print field (11A) specifies that the first data item in the PRINT USING statement must be a character string of not more than eleven characters in length. The second print field (4D) means that the second data item must be a numeric value of not more than four digits to the left of the decimal point. The fractional part of the number, if any, is rounded off in this case. Here is the resulting output:
Base Price: 6995
When line 100 is executed, the alphanumeric string "Base Price:" and the numeric constant "6995" are sent to the specified output device. The default print format normally used for FORMAT ON output is suppressed.
Notice that each print field specified in the format string has an accompanying data item specified in the PRINT USING statement. The data items are also of the correct type, a character string for the A field and a numeric value for the D field. If the data items were reversed in line 100, a data mismatch would occur, and program execution would halt with an error. If too many data items were specified in line 100 (three data items, for example instead of two), then the IMAGE string would have been reused and the third data item would need to be a string or an error would occur, and program execution would again halt. So, it is important that the type of data items specified in a PRINT USING statement, and the order in which they are specified, match the specifications of the format string.
Complex values and variables are treated as if they were two real variables. Therefore, no special item specifiers are needed for complex numbers.