7526 DCT Reference


Reference&mdash.Printer Port

reference&mdash.printer port

PrtChar

This function adds a string to the printer buffer. The data will be printed later during IdleManager calls, or after the CFR is exited. This function requires V2.00 microcode or higher, and a terminal that is printer-capable.

Note:

Data may not print on the printer until the printer receives an end-of-line character (hex 0D) or a carriage return - line feed sequence.
.

C Format

     #include   "cfrapi26.h"           // For defined values
 
     USHORT     PrtChar(character)
 
     UCHAR      character             // Character to print
 
     Returns:   E_OK                  // If no error occurred
                E_CONTEXT             // If port set for DIDO
                E_SPACE               // Printer buffer is full
                E_DEVICE              // Printer not ready

Masm Format

     Input:    ah = 00h
               al = character
 
     Call:     INT 46h
 
     Returns:  ax = 0       If no error occurred
                    3       If port set up for DIDO
                    6       Printer buffer is full
                    7       Printer prime failed

Example

int far main (int funct,char far *params)

PrtInit

This function initializes the parallel I/O port as a printer port and resets the printer buffer. This function requires V2.00 microcode or higher, and a terminal that is printer-capable.

Note:

When this function is used, the printer buffer is reset to the default 100 byte buffer, and any characters that have not yet been printed will be lost.
.

C Format

     #include   "cfrapi26.h"           // For defined values
 
     USHORT     PrtInit()
 
     Returns:   E_OK                  // If no error occurred
                E_CONTEXT             // If not using a printer capable
                                         //   processor board

Masm Format

     Input:    ah = 01h
 
     Call:     INT 46h
 
     Returns:  ax = 0       If no error occurred
                    3       If not using a printer capable
                              processor board

Example

int far main (int funct,char far *params)

PrtQuery

This function returns the status of the printer as a set of bit flags and also returns the POST completion code. This function requires V2.00 microcode or higher.

C Format

     #include   "cfrapi26.h"           // For defined values
 
     USHORT     PrtQuery(status, post)
 
     USHORT FAR *status            // Pointer to printer status
     USHORT FAR *post              // Pointer to POST completion code (always 0)
 
     Returns:   E_OK                  // If no error occurred

Masm Format

     Input:    ah = 02h
 
     Call:     INT 46h
 
     Returns:  bx = status
               dx = post    (always 0)
               ax = 0       If no error occurred
Comments:

The status represented by each bit is:

0
Printer select
1
Auto line feed enable
2
Paper out
3
Printer error
4
Printer busy
5
Port configuration (0 for printer, 1 for DI-DO)

Example

int far main (int funct,char far *params)

PrtQueryData

This function returns the number of characters left to print and the amount of free buffer space. This function requires V2.00 microcode or higher, and a terminal that is printer-capable.

C Format

     #include   "cfrapi26.h"           // For defined values
 
     USHORT     PrtQueryData(num_chars, space_remaining)
 
     USHORT FAR *num_chars            // Pointer to characters to print
     USHORT FAR *space_remaining      // Pointer to space remaining in
                                      //  printer buffer.
 
     Returns:   E_OK                  // If no error occurred
                E_CONTEXT             // If port set for DIDO

Masm Format

     Input:    ah = 03h
 
     Call:     INT 46h
 
     Returns:  bx = num_chars
               dx = space_remaining
               ax = 0       If no error occurred.
                    3       If port set up for DIDO

Example

int far main (int funct,char far *params)

PrtSetBuffer

This function changes the address of the printer buffer and the printer buffer size. The default printer buffer size is 100 bytes. The maximum size allowed is 65535 (64Kb - 1) bytes. This function requires V2.00 microcode or higher, and a terminal that is printer-capable.

Notes:

  1. If the new buffer selected is smaller than the previous buffer, the unprinted data will be truncated to the size of the new buffer. Otherwise, all data that has not yet been printed will be moved to the new printer buffer and then printed.

  2. The new buffer must not be a local stack variable, otherwise, when the current function is exited, it will be used by other functions for variable storage, giving indeterminate results for the printer output. l.

    C Format

         #include   "cfrapi26.h"           // For defined values
     
         USHORT     PrtSetBuffer(buffer, size)
     
         UCHAR FAR  *buffer               // Pointer to print buffer
         USHORT     size                  // Size of print buffer
     
         Returns:   E_OK                  // If no error occurred
                    E_CONTEXT             // If port set for DIDO
    

    Masm Format

         Input:    ah    = 04h
                   es:bx = buffer
                   cx    = size
     
         Call:     INT 46h
     
         Returns:  ax = 0   If no error occurred
                        3   If port set up for DIDO
    

    Example

    #define BUFSIZE  800
     
    UCHAR  buffer[BUFSIZE];           // New printer buffer
     
    int far main (int funct,char far *params)
    
    • {
      • USHORT size; // Size of the buffer to allocate
      • ·
      • // Set the size of the buffer to allocate
      • size = BUFSIZE;
      • if (PrtSetBuffer (buffer, size) == E_OK)
        • // New buffer allocated
        • ·
      • else
        • // Handle error
        • ·
    • }

    PrtSetStatus

    This function sets the mode of the line feeds for the printer. This function requires V2.00 microcode or higher, and a terminal that is printer-capable.

    C Format

         #include   "cfrapi26.h"           // For defined values
     
         USHORT     PrtSetStatus(status)
     
         UCHAR      status                // Printer status to set
     
         Returns:   E_OK                  // If no error occurred
                    E_PARAM               // If status was invalid
                    E_CONTEXT             // If port set for DIDO
    

    Masm Format

         Input:    ah = 05h
                   al = status
     
         Call:     INT 46h
     
         Returns:  ax = 0      If no error occurred
                        1      If status was invalid
                        3      If port set up for DIDO
    
    Comments:

    Example

    int far main (int funct,char far *params)
    
    • {
      • UCHAR status; // Linefeed mode selection
      • ·
      • // Select automatic linefeeds on carriage return
      • status = AUTO_LINEFEED_ON
      • if (PrtSetStatus (status) == E_OK)
        • // Automatic linefeeds are enabled
        • ·
      • else
        • // Handle error
        • ·
    • }

    PrtStr

    This function adds a string to the printer buffer. The data will be printed later during IdleManager calls, or after the CFR is exited. The default printer buffer size is 100 bytes, which may be increased by using the PrtSetBuffer command. This function requires V2.00 microcode or higher, and a terminal that is printer-capable.

    Note:

    Data may not print on the printer until the printer receives an end-of-line character (hex 0D) or a carriage return - line feed sequence.
    .

    C Format

         #include   "cfrapi26.h"           // For defined values
     
         USHORT     PrtStr(string, length)
     
         UCHAR FAR  *string               // Pointer to string to print
         USHORT     length                // Length of string
     
         Returns:   E_OK                  // If no error occurred
                    E_CONTEXT             // If port set for DIDO
                    E_SPACE               // Printer buffer was full
                    E_DEVICE              // If error while printing
    

    Masm Format

         Input:    ah    = 06h
                   es:bx = string
                   cx    = length
     
         Call:     INT 46h
     
         Returns:  ax = 0       If no error occurred
                        3       If port set up for DIDO
                        6       Printer buffer was full
                        7       If error while printing
    

    Comments:

    Special characters can be sent by binary value, or they may be embedded in strings to be printed by using a format of \x?? where ?? is the hexadecimal code of the character to be sent to the printer port. For example, to send a form feed to the printer, put the code \x0C in the string, at the point you want to go to the next page.

    The hex characters (\x??) count as four bytes in the length value if stored in a file in the terminal, but only one byte is sent to the printer.

    When using the IBM C/2 compiler, if a \x?? string is part of a string constant, it will be converted to a single character. So, it must be counted as one character for determining the number to put as the length value.

    Example

    int far main (int funct,char far *params)
    
    • {
      • UCHAR buffer [7]; // Date buffer
      • UCHAR string[18]; // String to go to the printer
      • USHORT length; // Length of the string
      • ·
      • // copy a string to the printer, and then give a form feed
      • strncpy(string, "Hello, world!\n\\x0C" , 18);
      • length = 18;
      • if (PrtStr(string, length) == E_OK)
        • // String sent out to the printer
        • ·
      • else
        • // Handle error
        • ·
    • }