Function IsPrinter() Foundation

Determines whether a printer is ready.

Syntax
IsPrinter( [<cLPT>] ) --> lReady
Parameters
<cLPT>
<cLPT> is a character string specifying the print channel whose readiness is determined. By default LPT1 is tested.
Return

The return value of IsPrinter() is .T. (true) if the printer (the device) on the specified print channel is ready, otherwise .F. (false) is returned.

Description

The environment function IsPrinter() tests the readiness of an output device connected to a print or output channel. The function tests LPT1 to LPT<n> or COM1 to COM<n>. When no argument is specified, the readiness of LPT1 is tested.

When print output occurs using the spooler or print queue, IsPrinter() reports the readiness of the spooler and not of the physical printer. In this situation the function generally returns the value .T. (true). If the actual output device is not ready, the condition is reported by the operating system.

Examples
IsPrinter()
// In the example, a text file is output to the 
// printer. Using IsPrinter(), the readiness of the printer 
// is tested during the print output. If it is not ready, 
// a message is output using Alert() and the user 
// decides how to continue. 
// 

PROCEDURE Main 
   LOCAL nLineLen := 55 
   LOCAL nPageLen := 65 
   LOCAL nPageNum := 1 
   LOCAL nPos 

   cString = MemoRead("TEXTFILE.TXT") 
   SET MARGIN TO 8 

   DO WHILE Len( cString ) > 0 
      SET PRINTER OFF 
      SET CONSOLE ON 

      DO WHILE .NOT. IsPrinter() 
         IF Alert( "Printer is not ready", ; 
                   {"Retry","Cancel"} ) == 2 
            cString := "" 
            EXIT 
         ENDIF 
      ENDDO 

      IF .NOT. Empty( cString ) 
         @ 0,0 SAY "Print page number:" 
         ?? nPageNum 

         SET PRINTER ON 
         SET CONSOLE OFF 
         ? PadL( "Page: "+Str(nPageNum,8), nLineLen ) 
         ? PadL( "Date: "+DtoC(Date())   , nLineLen ) 
         ? PadL( "Time: "+Time()         , nLineLen ) 

         nPos := MlPos( cString, nLineLen, nPageLen ) 

         ? SubStr( cString, 1, nPos - 1 ) 
         cString := SubStr( cString, nPos ) 

         nPageNum ++ 
         EJECT 
      ELSE 
         EXIT 
      ENDIF 
   ENDDO 

   SET MARGIN TO 
   SET PRINTER OFF 
   SET CONSOLE ON 

RETURN 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.