Microsoft KB Archive/30451

From BetaArchive Wiki

Article ID: 30451

Article Last Modified on 11/21/2006



APPLIES TO

  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft BASIC Professional Development System 7.0
  • Microsoft BASIC Professional Development System 7.1



This article was previously published under Q30451

SUMMARY

Below are two methods for making a screen dump of SCREEN 0, 1, or 2 (CGA modes) to an Epson or Epson-compatible printer. These methods also support all standard EGA and VGA SCREEN modes (SCREENs 7 through 13) if you are using the GRAPHICS.COM provided in MS-DOS 4.00 or later.

The examples below apply to Microsoft QuickBasic versions 4.00, 4.00b, and 4.50; to Microsoft Basic Compiler versions 6.00 and 6.00b; and to Microsoft Basic PDS (Professional Development System) versions 7.00 and 7.10 for MS-DOS. The program DUMP2.BAS below can be used with Microsoft QuickBasic versions 2.00, 2.01, and 3.00 if you change CALL INT86OLD to CALL INT86.

MORE INFORMATION

Printing CGA SCREEN Modes 0 Through 2

The following are two methods of performing a CGA screen dump to a graphics printer:

Note: These methods will also support all standard EGA and VGA SCREEN modes (SCREENs 7 through 13) if you are using GRAPHICS.COM provided in MS-DOS 4.00 or later.

  1. You can manually execute a screen dump to a graphics printer of a CGA SCREEN 0, 1, or 2 in Basic by doing the following:

    1. Run GRAPHICS.COM, which is a terminate-and-stay resident (TSR) program located on the DOS disk (run GRAPHICS.COM only once per boot session).
    2. Press SHIFT+PRINT SCREEN (that is, press the PRINT SCREEN key while holding down the SHIFT key).

      The above SHIFT+PRINT SCREEN screen dump also can print the screen in GW-Basic, in IBM BasicA, or in most programs that use CGA text or graphics.
  2. A hardware interrupt 5 also can be invoked to perform a CGA screen dump to a graphics printer from a Microsoft Basic program run on an IBM PC. To perform the screen dump, do the following:

    1. Run the GRAPHICS.COM program provided with the DOS disk (run GRAPHICS.COM only once per boot session).
    2. Once GRAPHICS.COM is resident in memory, using SHIFT+PRINT SCREEN or hardware interrupt 5 will print screens displayed by the IBM CGA card. In versions of MS-DOS earlier than 4.00, the IBM GRAPHICS.COM program does not support the printing of EGA or VGA screens, and only Basic SCREENs 0, 1, and 2 can be printed.

The following program, DUMP.BAS, shows the preferred method to CALL hardware interrupt 5 to perform a screen dump (this program can be compiled in QuickBasic 4.00, 4.00b, or 4.50; in Basic compiler 6.00 or 6.00b; or in Basic PDS 7.00 or 7.10 for MS-DOS):

   ' Dump.Bas
   TYPE Regtype

     AX AS INTEGER
     BX AS INTEGER
     CX AS INTEGER
     DX AS INTEGER
     BP AS INTEGER
     SI AS INTEGER
     DI AS INTEGER
     FLAGS AS INTEGER
     DS AS INTEGER
     ES AS INTEGER
   END TYPE
   DIM inary AS RegType
   DIM outary AS RegType
   CLS
   SCREEN 1
   PRINT "This goes to the printer"
   LINE (1,1)-(100,100)
   CALL interrupt (&H5, inary, outary)      ' Performs screen dump
                

The program below, DUMP2.BAS, can be used with Microsoft QuickBasic versions 2.00, 2.01, and 3.00 if you change CALL INT86OLD to CALL INT86. Otherwise, if you don't change CALL INT86OLD to CALL INT86, this program can be compiled as is in QuickBasic 4.00, 4.00b, or 4.50; in Basic compiler 6.00 or 6.00b; or in Basic PDS 7.00 or 7.10:

   ' DUMP2.BAS
   DIM inary%(7), outary%(7)
   SCREEN 1
   PRINT "This goes to the printer"
   LINE (1,1)-(100,100)
   CALL int86old ( &H5, VARPTR(inary%(0)), VARPTR(outary%(0)) )
   ' The following syntax, which leaves out the VARPTR function,
   ' is also supported in QuickBasic 4.00, 4.00b, 4.50, in Basic
   ' compiler 6.00 and 6.00b, and in Basic PDS 7.00 and 7.10:
   '         CALL int86old ( &H5, inary%(), outary%() )
   ' This INT86OLD syntax is given on Pages 86-88 of the "QuickBasic
   ' 4.0: Language Reference" for 4.00 and 4.00b and on Pages 86-88 of
   '"Basic Compiler 6.0: Language Reference" for 6.00 and 6.00b.
   'NOTE: The following syntax is ILLEGAL for CALL INT86 in
   'QuickBasic 2.00, 2.01, or 3.00:
   '           CALL int86 ( &H5, inary%(), outary%() )
                

To run the above DUMP.BAS or DUMP2.BAS program within the QB.EXE version 4.00, 4.00b, or 4.50 editor (or within QB.EXE from Basic compiler 6.00 or 6.00b), you must invoke the editor with the QB.QLB Quick library, as follows:

   QB DUMP.BAS /L QB.QLB
                

To make an EXE program from one of the above programs, you must LINK with QB.LIB as follows:

   BC DUMP.BAS;
   LINK DUMP.OBJ,DUMP.EXE,,QB.LIB;
                

The above LINK creates DUMP.EXE, which is a program that can be executed from DOS by typing "DUMP".

For Basic PDS version 7.00 or 7.10, you must use QBX.EXE, QBX.QLB, and QBX.LIB (instead of QB.EXE, QB.QLB, and QB.LIB) in the above steps.

DUMP.BAS cannot run in QuickBasic version 2.00, 2.01, or 3.00; instead, you must use DUMP2.BAS. To run DUMP2.BAS in QB.EXE version 2.00, 2.01, or 3.00, do the following:

  1. Make a USERLIB.EXE that contains INT86, as follows:

    1. In version 2.00 or 2.01, type the following at the DOS command line:

               BUILDLIB USERLIB.OBJ,userlib.EXE;
                                      
    2. In version 3.00, type the following at the DOS command line:

               BUILDLIB INT86.OBJ,userlib.EXE;
  2. Run GRAPHICS.COM (only once per boot session) if you will be printing graphics.
  3. Invoke QB.EXE as follows:

          QB DUMP2.BAS /L userlib.EXE
  4. Change INT86OLD to INT86 in DUMP2.BAS (since there is no INT86OLD in version 2.00, 2.01, or 3.00).
  5. Press CTRL+R to run the program in QB.EXE.

To make DUMP2.BAS into DUMP2.EXE using QuickBasic version 2.00, 2.01, or 3.00, do the following:

  1. Do ONE of the following:

    1. Create DUMP2.OBJ using the Compile command from the Run menu in the QB.EXE editor.
    2. You can also create DUMP2.OBJ using the separate compilation method, where you must end the QB command line with a semicolon (;), as follows:

               QB DUMP2;
  2. Do one of the following, depending on which version of QuickBasic you are using:

    1. In 2.00 or 2.01, type the following at the DOS command line:

               LINK DUMP2+USERLIB.OBJ;
                                      
    2. In 3.00, type the following at the DOS command line:

               LINK DUMP2+INT86.OBJ;


REFERENCES

This article is part of a collection of articles explaining how to print Basic video screens to Epson printers. Find the entire collection by querying in the Microsoft Knowledge Base using the following words:

Epson and print and screen and QuickBasic


If you want further information about video graphics memory, please refer to the following book, which is available from bookstores or Microsoft Press by calling (800) 888-3303 or (425) 882-8661:

"Programmer's Guide to PC and PS/2 Video Systems," by Richard Wilton (Microsoft Press, 1987)


Additional query words: QuickBas

Keywords: KB30451