BBS: Inland Empire Archive Date: 07-02-92 (13:41) Number: 2095 From: TOM HAMMOND Refer#: NONE To: BILL CAMPBELL Recvd: NO Subj: Lprint and printers Conf: (2) Quik_Bas
BC>Problem 1) BC>I want to trap for a device error (aka the printer is off-line) before my BC>program executes an Lprint command. DECLARE SUB PrinterCheck () ' Revised: 12/10/91 CALL PrinterCheck SUB PrinterCheck DEF SEG = 0 LPT% = 1 ' Use '1' for LPT1 and '2' for LPT2 Port% = PEEK(1030 + (2 * LPT%)) + (256 * PEEK(1031 + (2 * LPT%))) Status% = INP(Port% + 1) DO WHILE NOT Status% AND 8 CLS SOUND 600, 1 SOUND 800, 1 SOUND 1000, 1 LOCATE 11, 32 PRINT "Printer NOT READY" LOCATE 13, 25 PRINT "Set printer ON-LINE or TURN ON" SLEEP 2 CLS Status% = INP(Port% + 1) LOOP CLS DEF SEG END SUB -----------8<-------- Clip Here -----------8<--------------- or -----------8<-------- Clip Here -----------8<--------------- DECLARE SUB PrinterCheck (PrinterStatus%) 'Last touched: 03/04/92 Call PrinterCheck(PrinterStatus%) IF NOT PrinterStatus% THEN PRINT "Printer is OFF-LINE and you decided to leave it that way" ELSEIF PrinterStatus% = -1 PRINT "Printer was NOT OFF-LINE when tested" ELSEIF PrinterStatus% = 1 PRINT "Printer was OFF-LINE when tested but is ON-LINE now!" ELSE PRINT "Unspecified printer error" STOP END IF STOP SUB PrinterCheck (PrinterStatus%) 'Returns: 0 if printer is OFF-LINE and you want it that way ' -1 if printer is ON-LINE and was NOT off-line when tested ' 1 if printer is ON-LINE but WAS off-line when tested DEF SEG = 0 LPT = 1' USE LPT=1 FOR LPT1 AND LPT=2 FOR LPT2 PORT% = PEEK(1030 + (2 * LPT)) + 256 * PEEK(1031 + (2 * LPT)) PrinterStatus% = -1 PRINTER.STATUS.CHECK: Status% = INP(PORT% + 1) IF Status% AND 8 THEN DEF SEG EXIT SUB ELSE IF PrinterStatus% = -1 THEN CLS PrinterStatus% = 1 END IF AbortPrint$ = INKEY$ IF AbortPrint$ = CHR$(27) THEN PrinterStatus% = 0 EXIT SUB END IF LOCATE 9, 32 Txt$ = "Printer {NOT READY}" CALL ScrnCtr LOCATE 12, 25 Txt$ = "Set printer {ON-LINE} or {TURN ON}" CALL ScrnCtr LOCATE 14, 1 Txt$ = "or press <Esc> to abort the print request" CALL ScrnCtr FOR I% = 440 TO 880 STEP 20: SOUND I%, .1: NEXT FOR I% = 880 TO 440 STEP -20: SOUND I%, .1: NEXT LOCATE 9, 32 PRINT SPACE$(17) GOTO PRINTER.STATUS.CHECK END SUB -----------8<-------- Clip Here -----------8<--------------- BC>and Problem 2) BC>I want to Lprint a string but have it underlined. Assuming your printer uses standard EPSON/IBM control codes: Text$ = "This is printing test" LPRINT CHR$(27);CHR$(45);CHR$(1);Text$;CHR$(27);CHR$(45);CHR$(0) ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ Underlining ON Underlining OFF Good luck Tom Hammond N0SS --- þ SLMR 2.1 þ We all live in a yellow subroutine. --- WM v2.00/91-0231 * Origin: The Modem Zone BBS (314) 893-5106 (1:289/2)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET