The following examples illustrate how to combine characters into IMAGE strings. These examples use PRINT, but DISP, LABEL, or OUTPUT could also have been used to direct the output to various destinations.
The A character defines a field for alphanumeric character strings. The operator is specified in the form nA where n is an integer from 1 through 32767. If n is not specified, then 1 is the defaault. This example shows creation of an alphanumeric field:
A$ = "Greg Doe"
Image1: IMAGE 15A,2X,24A
PRINT USING Image1;"Student Name:",A$
The IMAGE statement above defines an alphanumeric field with 15 alphanumeric positions, 2 extra spaces, and then 24 more character positions. The PRINT statement outputs the string constant "Student Name:" in the first field, and "Greg Doe" in the last field.
The following shows how the output is printed relative to the field description. The first line shows the fields specified by the IMAGE string. The second line shows the PRINT output.
AAAAAAAAAAAAAAAXXAAAAAAAAAAAAAAAAAAAAAAAA
Student Name: Greg Doe
Notice that the character strings are left justified in the fields. This means that the first character in the string is printed in the left-most position in the field. The character string "Student Name:" only fills 13 character positions, the remaining positions are filled with space characters. Greg Doe fills 8 positions and the remaining 16 positions in that field are filled with space characters. Character strings larger than the specified field will be truncated.
The print position is set to a new line after each line is printed unless the IMAGE format ends with "#" to suppress the EOL. You would want to do this if you needed to continue output on the same line with another output statement.
Here is another PRINT USING example:
IMAGE "ERROR: ",2D,", ",K
Esc$=CHR$(27)
PRINT USING "A, ""[H"", A, ""[J"", #";Esc$,Esc$
PRINT USING 10;ERRN,"in line "&VAL$(ERRLN)
PRINT USING 10;19,"Out of range!"
PRINT USING 10;Error_code,"Oops!"
PRINT USING " ""The value of PI is"",X,1D.10D ";PI