HTBasic Help
×
Menu
Index

IMAGE

Defines the format for data input and output.
 
 IMAGE image-specifier [,image-specifier...]
 
Where:              image-specifier = # | % | K | -K | H | -H | B | W | Y | + | - | [n]A... | [n]X... | [n]/... | [n]L... | [n]@... | numeric-specifier | "string-literal"
numeric-specifier = [S|M] [left-digits] [.|R] [right-digits] [exp]
left-digits = [n]{D|Z|*}...
right-digits = [n]D...
exp = E | ESZ | ESZZ | ESZZZ
n = integer-constant repeat-factor (1 to 32767)
 
Usage:             IMAGE 4ZZ.DD,3X,K,/
PRINT USING """Results = "",SDDDE,3(XX,ZZ)";R,Array(*)
OUTPUT KBD USING "#,B,A"; 255,"K"
ENTER KBD USING 30;X
 
Example:           IMAGE.BAS
 
Description:
Executing an IMAGE statement by itself does nothing. The IMAGE statement is used to format data for the ENTER, OUTPUT, DISP, LABEL and PRINT USING statements. These statements may use an IMAGE statement as their format by specifying the line number or label name of the IMAGE statement. Alternately, they can contain a string expression containing the image. To embed quotation marks in a string literal, include two quotation marks.
 
A complex number is treated like two real numbers and should be specified with two image specifiers. The first specifier defines how the real part should be output/entered and the second specifier does the same for the imaginary part.
 
The image specifiers in the image list are acted upon as they are encountered. Each specifier should have a matching OUTPUT/ENTER item. Processing of the image list stops when no matching OUTPUT/ENTER item is found. Conversely, the image list is reused starting at the beginning to provide matches for all remaining OUTPUT/ENTER items.
 
If more decimal places to the left of the decimal point are required to output a numeric item than are specified in the image specifier, an error is generated. If M or S are not specified, then a minus sign will take up one digit place. If the number contains more decimal places to the right of the decimal point than are specified in the image field, the output is rounded to fit.
 
If the number of characters specified in an image specifier for a string is less than the number of characters in a string, then the remaining characters are ignored. If the number of characters specified is greater than the number of characters in a string then trailing blanks are used to fill out the image field.
 

OUTPUT

 
IMAGE specifiers have the following meanings in an ENTER statement:
#
Suppress automatic output of EOL following the last item.
%
Is ignored in OUTPUT images.
K
Output a number or string in default format, with a period for the radix.
-K
Means the same thing as K.
H
Output a number or string, default format, comma radix.
-H
Means the same thing as H.
B
Output a byte, like the CHR$ function. If the value is larger than 32767, 255 is sent. If the value is smaller than -32768, 0 is sent. If the value is in between, it is rounded to an integer and the least significant byte (CINT(value) MOD 256) is sent.
W
Output a word in 2's complement 16-bit integer form. If the value is larger than 32767, 32767 is sent. If the value is smaller than -32768, -32768 is sent. If the interface is 16-bit, the word is output in one operation (even if the BYTE attribute was used in the I/O path). If the interface is 8-bit, the byte ordering depends on the LSB/MSB attribute of the I/O path. If the destination is a string, native byte ordering is always used (LSB FIRST on a PC, MSB FIRST on a Sun or HP Workstation). If the WORD attribute was specified in the I/O path, a pad byte will be output before the word when necessary to achieve word alignment.
Y
Means the same as W, except that word alignment is not done and the BYTE attribute is not ignored.
+
Change the automatic output of EOL to carriage-return after the last item.
-
Change the automatic output of EOL to line-feed after the last item.
M
Output a minus sign if negative, a blank if positive.
S
Output the sign of the number (+ or -).
D
Output one numeric digit character. The leading zero's are replaced by blanks, a minus sign is displayed on negative numbers.
Z
Means the same thing as D except leading zeros are displayed.
*
Means the same thing as D except leading zeros are replaced with asterisks.
.(period)
Output a decimal-point radix indicator.
R
Output a comma radix indicator.
E
Output an 'E', a sign character and a two-digit exponent.
ESZ
Output an 'E', a sign character and a one-digit exponent.
ESZZ
Output an 'E', a sign character and a two-digit exponent.
ESZZZ
Output an 'E', a sign character and a three-digit exponent.
A
Output an alphanumeric string character.
X
Output a blank.
/
Output a carriage-return and line-feed.
L
Output the current EOL sequence. The default is CR/LF.
@
Output a form-feed character.
"string literal"
Output the characters in the string literal. Remember to double the quote marks when the image is not in an IMAGE statement.
 

ENTER

 
IMAGE specifiers have the following meanings in an ENTER statement:
#
Causes the statement to terminate when the last item is terminated. No statement terminator is needed, EOI and LF are item terminators and early termination is not allowed.
%
Is the same as # except EOI causes early statement termination when it terminates an item.
K
Allows free-field entry. For numerics, entered characters are sent to the number builder, leading non-numeric characters and blanks are ignored, trailing non-numeric characters and characters sent with EOI true are delimiters. For strings, entered characters are sent to the string. A CR may be sent to the string if it is not followed by a LF. The string is terminated by CR/LF, LF, character received with EOI true or the string dimensioned length being filled.
-K
Is like K except LF and CR/LF are not terminators.
H
Is the same as K except a comma is the radix indicator and a period is a non-numeric character.
-H
Means the same as -K for strings and H for numbers.
B
Demands one Byte, like the NUM function.
W
Demands a 16-bit Word (2's complement integer). If the interface is 16-bit, the word is entered in one operation (even if the BYTE attribute was used in the I/O path). If the interface is 8-bit, the byte ordering depends on the LSB/MSB of the I/O path. If the source is a string, native byte ordering is always used (LSB FIRST on a PC, MSB FIRST on a Sun or HP Workstation). If the WORD attribute was specified in the I/O path, a pad byte will be entered before the word when necessary to achieve word alignment.
Y
Is the same as W, except that word alignment is not done and the BYTE attribute is not ignored.
+
Indicates an END (EOI) is needed with the last character of the last item to terminate the ENTER statement. LFs are no longer statement terminators, but are still item terminators.
-
Indicates a LF is needed to terminate the ENTER statement. EOI is ignored; other END indicators cause an error.
M
Same meaning as D.
S
Same meaning as D.
D
Demands one character for each D or repeat count. Non-numerics are consumed while fulfilling the count but also delimit the number. Blanks embedded in the number are ignored.
Z
Same meaning as D.
*
Same meaning as D.
.(period)
Same meaning as D.
R
Has the same meaning as D, plus the number builder is instructed to use a  comma as the radix indicator and a period as a non-numeric character.
E
Is treated the same as 4D.
ESZ
Same as 3D.
ESZZ
Same as 4D.
ESZZZ
Same as 5D.
A
Demands one alphanumeric string character.
X
Enters a character and discards it.
/
Skips all characters to the next LF. EOI is ignored.
L
Ignored in ENTER.
@
Ignored in ENTER.
"string literal"
One character is skipped for each character in the string literal. Remember to double the quote marks when the image is not in an IMAGE statement.
 

Porting Issues

Note that entering data from a string, as in ENTER L$ USING "Y", the byte ordering for Windows computers is least significant byte (LSB) first, whereas for HP Workstations and Sun SPARCstations, the byte ordering is most significant byte (MSB) first. This limitation applies to ENTER/OUTPUT with strings only. With devices, the byte ordering can be selected in the ASSIGN statement.
 
See Also: