Function IsPrinter() Foundation
Determines whether a printer is ready.
IsPrinter( [<cLPT>] ) --> lReady
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.
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.
// 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
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.