home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s1.arc / INITPRIN.MOD < prev    next >
Text File  |  1988-01-08  |  3KB  |  86 lines

  1. (*----------------------------------------------------------------------*)
  2. (*               Initialize_Printer --- Initialize Printer              *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Initialize_Printer;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Procedure:  Initialize_Printer                                   *)
  10. (*                                                                      *)
  11. (*     Purpose:    Initializes Printer                                  *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        Initialize_Printer;                                           *)
  16. (*                                                                      *)
  17. (*----------------------------------------------------------------------*)
  18.  
  19. VAR
  20.    Ch        : CHAR;
  21.    Regs      : Registers;
  22.    LstHandle : WORD ABSOLUTE Lst;
  23.  
  24. BEGIN (* Initialize_Printer *)
  25.                                    (* Assign printer device *)
  26.    ASSIGN ( Lst , 'PRN' );
  27.    REWRITE( Lst );
  28.                                    (* Check if this went OK *)
  29.    Lst_OK := ( Int24Result = 0 );
  30.                                    (* Ensure printer file is in binary mode *)
  31.    WITH Regs DO
  32.       BEGIN
  33.  
  34.          AX := $4400;              (* IOCTL sub function 0 - Get device information. *)
  35.          BX := LstHandle;          (* Device information is returned in DX.          *)
  36.  
  37.          MsDos( Regs );
  38.  
  39.          AX := $4401;              (* IOCTL sub function 1 - Set device information. *)
  40.                                    (* New device setting is passed in DX.            *)
  41.                                    (* Set bit 5 of DX so data is passed in "raw"     *)
  42.                                    (* mode through LST device.                       *)
  43.  
  44.          DX := ( DX AND $00FF ) OR $0020;
  45.  
  46.          MsDos( Regs );
  47.  
  48.       END;
  49.                                    (* If printer setup string is not null, *)
  50.                                    (* try sending it to printer.           *)
  51.  
  52.    IF ( LENGTH( Printer_Setup ) > 0 ) THEN
  53.       BEGIN
  54.  
  55.          WRITE( Lst , Printer_Setup );
  56.          Lst_OK := ( Int24Result = 0 );
  57.  
  58.          IF ( NOT Lst_OK ) THEN
  59.             BEGIN
  60.  
  61.                WRITELN('*** Printer appears to be turned off or out of paper.');
  62.                WRITELN('*** Please fix that and then press ESC key to continue.');
  63.  
  64.                IF Attended_Mode THEN
  65.                   BEGIN
  66.                      Read_Kbd( Ch );
  67.                      IF ( Ch = CHR( ESC ) ) AND PibTerm_KeyPressed THEN
  68.                         Read_Kbd( Ch );
  69.                   END
  70.                ELSE
  71.                   WRITELN('*** Continuing anyway because of unattended mode.');
  72.  
  73.             END;
  74.  
  75.          WRITE( Lst , Printer_Setup );
  76.          Lst_OK := ( Int24Result = 0 );
  77.  
  78.          IF Lst_OK THEN
  79.             WRITELN('Printer initialization completed.')
  80.          ELSE
  81.             WRITELN('Printer initialization could not be done.')
  82.  
  83.       END;
  84.  
  85. END   (* Initialize_Printer *);
  86.