Slow Printer

 BBS: Inland Empire Archive
Date: 03-19-92 (14:32)             Number: 115
From: STEVE GARTRELL               Refer#: NONE
  To: GREG ALHO                     Recvd: NO  
Subj: Slow Printer                   Conf: (2) Quik_Bas
'If this works, just use FixPrint NewTries% PrinterNum%
'in future programs, where NewTries% is the number shown
'at the end of the program's run.  PrinterNum% is obvious.
'If it doesn't work, it'll say so.  Do make sure
'that your printer is on line ready to go...These changes
'aren't permanent; they'll disappear as soon as ya
'reboot.  Basically, all this does is attempt a big
'print; if it times out, it increases the number of
'retries the BIOS will make before freakin' out up to
'the maximum of 256.  If it hits 256, it quits and reloads
'the original value...It may burn some paper before it
'finds a good value or gives up...|-}

DEFINT A-Z
DECLARE FUNCTION PokeyPrinter% (PrinterNum%)
DECLARE SUB FixPrint (NewTries%, PrinterNum%)

DIM SHARED PrintFlag%

CLS

'1 = lpt1, 2 = lpt2, 3 = lpt3, 4 = lpt4
PrinterNum% = 1

LOCATE 23, 1
Tries% = PokeyPrinter%(PrinterNum%)

SELECT CASE Tries%
   CASE IS > 256, 0
   PRINT "Didn't help ya; sorry!";
   CASE ELSE
   PRINT "Use "; LTRIM$(STR$(PrinterNum%)); " when calling FixPrint.";
END SELECT



END
PrintError:
PrintFlag% = -1
RESUME NEXT

SUB FixPrint (NewTries%, PrinterNum%)

IF PrinterNum% > 0 THEN
   PrinterNum% = PrinterNum% - 1
ELSE
   PrinterNum% = 0
END IF

PrnTriesAddr% = &H78 + PrinterNum%
DEF SEG = &H40

POKE PrnTriesAddr%, NewTries%

DEF SEG

END SUB

FUNCTION PokeyPrinter% (PrinterNum%)

IF PrinterNum% > 0 THEN
   PrinterNum% = PrinterNum% - 1
ELSE
   PrinterNum% = 0
END IF

PrnTriesAddr% = &H78 + PrinterNum%

DEF SEG = &H40
StoreTries% = PEEK(PrnTriesAddr%)
DEF SEG
IF StoreTries% = 0 THEN
 StoreTries% = 16
END IF
CurrentTries% = StoreTries%
ON ERROR GOTO PrintError
PrintError% = 0
Prn$ = "01234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

DO
   FOR cnt% = 1 TO 40
   LPRINT Prn$;
   IF PrintFlag% THEN EXIT FOR
   NEXT cnt%
   IF PrintFlag% THEN
   PrintFlag% = 0
   CurrentTries% = CurrentTries% + 4
   DEF SEG = &H40
   IF CurrentTries% > 256 THEN
   POKE PrnTriesAddr%, StoreTries%
   DEF SEG
   PokeyPrinter% = CurrentTries%
   EXIT FUNCTION
   ELSE
   POKE PrnTriesAddr%, CurrentTries%
   DEF SEG
   start! = TIMER + .5
   DO: LOOP UNTIL TIMER > start!
   END IF
   ELSE
   IF CurrentTries% > StoreTries% THEN
   PokeyPrinter% = CurrentTries%
   ELSE
   PokeyPrinter% = 0
   END IF
   EXIT FUNCTION
   END IF
LOOP

ON ERROR GOTO 0

END FUNCTION


--- DB B1061/071082
 * Origin: RadioLink! Columbus, OH (614)766-2162 HST/DS 1:226/140 (1:226/140)
Outer Court
Echo Basic Postings

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