File – AMT Datasouth PAL User Manual
Page 106

file
100
All PAL printers recognize the following standard file names.
%stdin
Standard input file. Normally the communications port connected to the host
computer. Read-only access.
%stdout
Standard output file. Normally the communications port connected to the host
computer. Write-only access.
%stderr
Standard error output file. Normally the same as %stdout. Write-only access.
Some PAL printers, depending on their available features, will recognize various combinations of
the following standard files.
%keybrd
Keyboard. Normally associated with a PS/2 style keyboard. Usually an add-on
option available for the printer. Read-only access.
%keypad
Keypad. Normally associated with a printer's front panel key pad.
A file remains open for as long as the programmer maintains any reference to the file's associated
file object. PAL automatically closes a file once the programmer eliminates all references to the
file's associated file object. The following examples demonstrate the file open and close process.
1:
(%stdin) (r) file
2:
(123) readstring == ==
1:
<<>> begin
2:
/HostRead (%stdin) (r) file def
3:
HostRead (123) readstring == ==
4:
HostRead (123) readstring == ==
5:
end
The first example attempts to read three characters from the %stdin file. Line 1 opens the file. At
the end of line 1, PAL has left the file's associated file object on the top of the stack. Line 2 uses
this file object, plus the string required by the readstring operator to perform a read from %stdin.
The == operators write the results of the readstring operation to %stdout. readstring removes
the file object and the required string from the stack. Since this eliminates all references to the file
object from the printer's memory, PAL automatically closes the file upon completion of the
readstring operation.
The second example attempts to read six characters from the %stdin file. Line 1 places an empty
dictionary on the top of the stack to host the HostRead variable. Line 2 opens the %stdin file and
saves the associated file object under the name HostRead in the previously empty dictionary.
Lines 3 and 4 then recover this file object and attempt to read three characters from %stdin. Line 5
discards the temporary dictionary from the dictionary stack. Since that dictionary contained the
only reference to the %stdin file object, PAL automatically closes the file after discarding the
dictionary.