home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 18 / CD_ASCQ_18_111294_W.iso / dos / prg / pas / theprn25 / demo_prn.bas < prev    next >
BASIC Source File  |  1994-07-24  |  4KB  |  112 lines

  1. DEFINT A-Z
  2.  
  3. '==========================================================================
  4. '
  5. '    Name:       Demo_Prn.Bas   Copyright 1992-1994, Rob W. Smetana
  6. '             
  7. '                The Printer (tm) support file.
  8. '
  9. '                NOTE:  PowerBASIC users must UN-REM one line below.
  10. '
  11. '
  12. ' Purpose:       * Demonstrate reading printer records.
  13. '
  14. '                * Demonstrate using TYPE.INC (and when not to).
  15. '
  16. '                * Show how one might display printer codes.
  17. '
  18. '                  Something like this might be used inside a
  19. '                  program to show users which codes are
  20. '                  available (ie., not blank) and perhaps what
  21. '                  they should do to invoke each option.
  22. '
  23. '    NOTE:       Some printer codes may contain control codes which screw
  24. '                up the display when printed.  Try a different printer.
  25. '                And in your own programs you might want to use an ASM
  26. '                "quickprint" routine to overcome this problem.
  27. '
  28. 'Requires:       Printer.Cfg.  BEFORE running this, you MUST run Printer.Exe,
  29. '                select a printer, and press F2 to SAVE Printer.Cfg.
  30. '                THIS program will display the contents of Printer.Cfg.
  31. '
  32. '                The_Prn.Bas, an "include file" containing 2 TYPES you
  33. '                may use to read printer control codes.
  34. '
  35. '==========================================================================
  36.  
  37. '...include two TYPES useful for reading printer codes.
  38.  
  39. '$INCLUDE: 'The_Prn.Bas'       '<<--- Microsoft BASICS (QB, PDS, VBDOS)
  40.  
  41. ''$INCLUDE "The_Prn.Bas"       '<<--- PowerBASIC users, UN-REM this line
  42.  
  43. '...NOTE:  Although we loaded a TYPE to read printer codes, we won't use it!
  44. '   For what we're about to do, it's more code efficient to read stuff
  45. '   using some simple 980-byte strings.
  46.  
  47. Labels$ = SPACE$(980)
  48. Codes$ = Labels$
  49.  
  50. COLOR , 1: CLS
  51.  
  52. OPEN "Printer.Cfg" FOR BINARY AS #1         '...this MUST already exist!!!
  53. IF LOF(1) < 2000 THEN
  54.    CLOSE
  55.    PRINT "Error:  Printer.Cfg may not exist or it's too small.  Run Printer.Exe,"
  56.    PRINT "select a printer, then press F2 to save codes to Printer.Cfg."
  57.    END
  58. END IF
  59.  
  60.     GET #1, , Header                        '...we WILL use the header
  61.     GET #1, , Labels$                       '...so we can print descriptions
  62.  
  63.     GET #1, , Header                        '...Get again so we're in position
  64.                                             '   to read codes.
  65.     GET #1, , Codes$                        '...so we can print printer codes
  66.  
  67. CLOSE
  68.  
  69. '...Now display them
  70.  
  71.  
  72. PRINT "   You chose a printer made by :  "; Header.Manufacturer;
  73. PRINT "                  The Model is :  "; Header.Model
  74.  
  75. IF LEN(RTRIM$(Header.EmMode)) THEN       '...if it's emulating another ...
  76.  
  77.     PRINT "     This printer is emulating :  "; RTRIM$(Header.EmMode)
  78.     It.Is.Emulating = -1
  79.  
  80. END IF
  81.  
  82. PRINT : PRINT
  83.  
  84. '...Now for the codes
  85.  
  86. FOR x = 1 TO 70
  87.  
  88.     '...Starting at column 1, print 70, 14-byte fields.
  89.  
  90.     Where = 1 + ((x - 1) * 14)
  91.  
  92.  
  93.     '...Printing this way is simpler than printing separate TYPE members.
  94.  
  95.     PRINT "     "; MID$(Labels$, Where, 14); "   "; MID$(Codes$, Where, 14),
  96.  
  97.  
  98.     '...They won't all fit on 1 screen, so pause, then display the rest.
  99.  
  100.     IF CSRLIN > 22 AND x < 70 THEN
  101.  
  102.        LOCATE 25, 20: PRINT "Press any key to see the rest . . .";
  103.        d$ = INPUT$(1)
  104.  
  105.        LOCATE 5, 1
  106.        IF It.Is.Emulating = False THEN PRINT
  107.  
  108.     END IF
  109.  
  110. NEXT
  111.  
  112.