home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / THEPRN14.ZIP / DEMO_PRN.BAS < prev    next >
BASIC Source File  |  1994-01-15  |  3KB  |  103 lines

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