Printing to a DOS File or Device
All forms of terminal printing including screen dump, hardcopy and direct printing are supported.
Printer output can be generated via an AiF sequence from the Host or from within HostAccess, and can be directed to a DOS disk file or to a printer on the PC. The print destination can either be set through the Print Setup... option on the Session menu or from the host application using an AiF sequence. This destination name will only affect the currently active session.
All terminal emulation protocol specific printing commands are supported, for example McDonnell Douglas' PORTOUT. However, it is recommended that you use the ANSI sequences given below as they are supported in all the terminal emulations available (and so applications will only need to support one set of terminal printing sequences).
Printing AiF Sequences
ESC [ = 0 i |
Print screen to current print device. |
ESC [ = 4 i |
Switch OFF direct printing. |
ESC [ = 5 i |
Switch ON direct printing to current print device. |
ESC [ = 8 i |
Closes the printer, even when the keep printer open feature is enabled. |
To change the current DOS device for printing for the currently active session, use the following sequence:
ESC _ L device.name ESC \
Where:
|
Is the DOS device or filename into which all print output should be directed for this session. It could be LPT1, LPT2, COM1 or COM2 if you have a printer on one of those devices or it could be a DOS file name. To reset to the default printer use PrintManager. |
|
Printing Examples
To send print data to a printer on parallel port 1 use the following 'code':
SET DEVICE send to PC 'ESC_LLPT1ESC \'
PRINT ON send to PC 'ESC[=5i'
send to PC print_data_lines
PRINT OFF send to PC 'ESC[=4i'
To switch printing to the DOS file C:\PRINT.LST and to append a dump of the screen contents to it, use the following 'code':
SET DEVICE send to PC 'ESC_LC:\PRINT.LSTESC \'
DUMP SCREEN send to PC 'ESC[=0i'
If you are using the Host Printing facility of HostAccess's File Services, do not attempt to direct HostAccess DOS printing to this device.
When printing to a DOS file, this file is always appended to. If this is not required, delete the file before printing commences. This may be done by using the Erase DOS File AiF sequence (for more information see the following section).
AiF has an additional 'printing' feature that enables screens to be sent back to the host system (for details see Capturing Screen Text).
Printing to a USB Printer
If you wish to direct print output to a USB printer you will need to instruct Windows to map the USB printer to a given LPT port.
You will first need to share the USB printer and then run the following command:
net use LPT1: \\ServerName\PrinterName /persistent:yes
Where:
|
Is the name of the server sharing the printer |
|
Is the share name of the printer |
Erase DOS File
Host applications that pipe data to DOS files often need to delete the target DOS file at some stage within their processing. Applications will want this to happen transparently to the user (i.e. without the need of invoking the DOS gateway and executing the DOS Del command).
This is easily achieved by using the AiF sequence that follows.
ESC _ E filename ESC \
Where:
|
Is the name of the DOS file to be deleted, including its filename extension and the full DOS drive:\path to the file. |
Examples
To delete the DOS file called TEMP.DOC in the DOS drive:\path C:\HOST, use the following sequence:
send to PC 'ESC_E C:\HOST\TEMP.DOC ESC \'
No indication or request for confirmation of the file deletion is given to either the user or the host application. It is the application's responsibility to verify that the correct file has been deleted, if this is required. If the DOS file to be deleted does not exist, control is simply returned uninterrupted to the host application.
See Verify DOS File or Directory Exists if you need an AiF sequence to verify the existence of a DOS file.
Request HostAccess DOS Run Directory
Host applications can request that HostAccess tells them from which DOS directory HostAccess is running.
It is often useful for host applications to be aware of the current run-time DOS path so that this can be used to store temporary DOS files, for example, when automating file transfer.
This can be achieved by using the following AiF sequence:
ESC [ = 9 {; code} n
Where:
Code |
0* = Working directory, long file name format |
|
1 = Installation directory, long file name format |
|
2 = Temp directory, long file name format |
|
8 = Working directory, short file name format |
|
9 = Installation directory, short file name format |
|
10 = Temp directory, short file name format. |
HostAccess responds with the following message:
<STX> <CR> path <CR>
Where:
<STX>
|
Is a special start of text character (ASCII decimal value 002). |
|
Is the full DOS drive and path to the HostAccess run-time directory, e.g. |
|
C:\HOSTACC\HOST.EXE |
|
Is a carriage return (ASCII decimal value 013). |
Examples
To request the current HostAccess run-time directory, use the following sequence:
send to PC 'ESC[=9n'
loop input response until response equals STX do repeat
input pc_path
DOS_run_drive = first two characters of pc_path
DOS_run_directory = all characters after the last "\" delimiter
in the pc_path string
Request HostAccess System Information
This AiF sequence may be used to find out more information about the system running HostAccess.
Use the following sequence to get the HostAccess System Information:
ESC _ 84 ; type w {variable} ESC \
Where:
type
|
The type of information HostAccess should return: 1. Printer Information 2. Date and Time 3. Date 4. Time 5. Computer Name and User Name 6. Computer Name 7. User Name 8. Environment Variable |
|
The environment variable. Used only when type = 8. |
This returns:
<STX> <CR> data <CR>
Where:
<STX>
|
Is the start of text character (ASCII decimal value 002). |
|
Is carriage return (ASCII decimal value 013). |
|
Is the data returned e.g. Computer Name, User Name, Date and/or Time etc |
Verify DOS File or Directory Exists
Host applications that manipulate DOS files (e.g. through HostAccess's file transfer, FORMs or direct print facilities) often need to check the existence of the target DOS file at some stage within their processing. Applications will want this to happen transparently to the user.
This can be achieved by using the AiF sequence that follows.
ESC _ G path ESC \
Where G
is the capital letter 'G'.
path
|
Is the name of the DOS file or directory to be verified, including its filename extension and the full DOS drive:\path to the file. |
HostAccess answers this inquiry with a response in the following format:
<STX> <CR> code <CR>
Where:
<STX>
|
Is the start of text character (ASCII decimal value 002). |
|
Is carriage return (ASCII decimal value 013). |
|
Is an integer code that answers the verification request as one of the following: 0 (DOS path does not exist), 1 (DOS File exists) or 2 (DOS Directory exists). |
Verify DOS File Examples
To verify the DOS file called TEMP.DOC in the DOS drive:\path C:\HOST, use the following sequence:
send to PC 'ESC_G C:\HOST\TEMP.DOC ESC\'
loop until input_string equals STX do repeat
input response
if response equals 0 print "File does NOT exist !!"
if response equals 1 print "File exists"
if response equals 2 print "TEMP.DOC is a DIRECTORY !!"