home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / BASIC / BASIC00.ZIP / PRINTER.BAS < prev    next >
Encoding:
BASIC Source File  |  1987-01-11  |  4.9 KB  |  144 lines

  1. 10 'printer
  2. 20 'Program to deal with the IBM 80 cps printer (Epson MX80)
  3. 30 'Functions:  Setup printer modes
  4. 40 '            Print paginated listings of text files
  5. 50 '            Issue controls to printer
  6. 60 'Author:     Will Fastie
  7. 70 'Created:    12 Dec 1981
  8. 80 'Modified:   Bill Linhart    4-3-82, 7-13-82
  9. 90 'Source:     printer.bas
  10. 100 'NOTE:      Operates on current display device, current mode
  11. 110 '************* Constants ***************************
  12. 120 PROG$ = "PRINTER v1.03 7-13-82"
  13. 130 ESC$ = CHR$(27)
  14. 135 QUO$ = CHR$(34)
  15. 140 CLRLPT$ = CHR$(18) + CHR$(20) + ESC$ + "F" + ESC$ + "H"
  16. 150 PWIDTH = 80
  17. 160 '************* Initial Menu ************************
  18. 170 KEY OFF: CLS: SCREEN 0,0,0
  19. 180 PRINT PROG$: PRINT
  20. 190 PRINT "The printer must be ONLINE to "
  21. 200 PRINT "perform these functions."
  22. 210 PRINT
  23. 220 PRINT "Functions:";
  24. 230 PRINT TAB(13) ;"P - Print a text file"
  25. 240 PRINT TAB(13) ;"S - Setup printer"
  26. 250 PRINT TAB(13) ;"R - Reset printer"
  27. 260 PRINT TAB(13) ;"T - Advance paper to top"
  28. 270 PRINT TAB(13) ;"Q - Quit (return to DOS)"
  29. 280 PRINT TAB(13) ;"X - Exit to Basic"
  30. 290 MENSEL = CSRLIN + 1
  31. 300 PLOC = MENSEL: GOSUB 1270
  32. 310 INPUT "   Enter function:  ",X$: IF X$ = "" THEN BEEP: GOTO 300
  33. 320 GOSUB 1210
  34. 330 X = INSTR("PSRTQX",X$): IF X = 0 THEN BEEP: GOTO 300
  35. 340 ON X GOSUB 360, 770, 1080, 1120,1150, 1180
  36. 350 GOTO 160
  37. 360 '**************** Print paginated listing ********************
  38. 370 CLS
  39. 380 PRINT PROG$: PRINT
  40. 390 PRINT "Adjust the paper in the printer so that"
  41. 400 PRINT "the perforation is at the paper bail."
  42. 410 PRINT "Put the printer ONLINE.
  43. 420 PRINT
  44. 430 PRINT "Files MUST be ASCII text files."
  45. 434 PRINT "Create ASCII files by using..."      '7-13-82
  46. 435 PRINT "   SAVE" QUO$ "filename.ext" QUO$ ",A"  '7-13-82
  47. 440 PRINT
  48. 450 PRINT "No filename extension is assumed,"
  49. 460 PRINT "so enter the filename exactly."
  50. 470 PRINT "Depress ENTER key to return to menu."
  51. 480 PRINT "Press ESC key to abort printing."
  52. 490 PRINT
  53. 500 INPUT "File to print:  ", X$
  54. 510 IF LEN(X$) = 0 THEN RETURN
  55. 520 GOSUB 1210
  56. 530 WIDTH "lpt1:", PWIDTH
  57. 540 OPEN X$ FOR INPUT AS 1
  58. 550 PAGENR = 0
  59. 560 LINENR = 1
  60. 570 IF EOF (1) THEN 650
  61. 580 LINE INPUT #1, L$
  62. 590 IF LINENR = 1 THEN GOSUB 700
  63. 600 LPRINT L$
  64. 610 IF INKEY$ = ESC$ THEN 650
  65. 620 LINENR = LINENR + INT((LEN(L$)+79)/80)
  66. 630 IF LINENR > 54 THEN LINENR = 1
  67. 640 GOTO 570
  68. 650 '******************** Close file and return **********************
  69. 660 CLOSE
  70. 670 GOSUB 1120
  71. 680 GOTO 500
  72. 690 '******************** Subroutine to print page heading ***********
  73. 700 IF PAGENR <> 0 THEN LPRINT  CHR$(12);
  74. 710 PAGENR = PAGENR + 1
  75. 720 LPRINT: LPRINT
  76. 730 LPRINT CHR$(14); X$; " "; CHR$(20);
  77. 740 LPRINT "-- printed on ";DATE$;" at "; TIME$; " -- Page";PAGENR
  78. 750 LPRINT : LPRINT
  79. 760 RETURN
  80. 770 '******************** Setup Printer ******************************
  81. 780 CLS: PRINT PROG$
  82. 790 PRINT : PRINT  "Printer enhancements are:"
  83. 800 PRINT
  84. 810 PRINT "    DW - Double Width"
  85. 820 PRINT "    C  - Compressed Print"
  86. 830 PRINT "    E  - Emphasized Print"
  87. 840 PRINT "    DS - Double Strike"
  88. 850 PRINT
  89. 860 PRINT "Enter enhancements separated by spaces."
  90. 870 PRINT
  91. 880 PRINT "Examples:"
  92. 890 PRINT
  93. 900 PRINT "  C E    - Illegal"
  94. 910 PRINT "         - 10 cpi, normal"
  95. 920 PRINT "  E      - 10 cpi, bold"
  96. 930 PRINT "  DS C   - 16.5 cpi, double"
  97. 940 PRINT
  98. 950 INPUT "      Enter enhancements:  ",O$
  99. 960 X$=O$: GOSUB 1210: O$=X$
  100. 970 LPRINT CLRLPT$;
  101. 980 IF INSTR(O$,"DW") THEN LPRINT CHR$(14);
  102. 990 IF INSTR(O$,"C") THEN LPRINT CHR$(15);
  103. 1000 IF INSTR(O$,"E") THEN LPRINT ESC$;"E";
  104. 1010 IF INSTR(O$,"DS") THEN LPRINT EXC$;"G";
  105. 1020 PRINT
  106. 1030 PLOC = CSRLIN
  107. 1040 GOSUB 1270
  108. 1050 INPUT "Enter desired line width:  "; PWIDTH
  109. 1060 IF 1 > PWIDTH  OR PWIDTH > 132 THEN 1040
  110. 1070 RETURN
  111. 1080 '************************ Reset printer to defaults ****************
  112. 1090 LPRINT CLRLPT$;
  113. 1100 PWIDTH = 80
  114. 1110 RETURN
  115. 1120 '******************* Form feed to printer **************************
  116. 1130 LPRINT CHR$(12);
  117. 1140 RETURN
  118. 1150 '******************* Return to DOS *********************************
  119. 1160 CLS
  120. 1170 SYSTEM
  121. 1180 '******************* Exit to Basic *********************************
  122. 1190 CLS
  123. 1200 END
  124. 1210 '******************* Subroutine to UPPERFY a string (in X$) ********
  125. 1220 FOR X = 1 TO LEN(X$)
  126. 1230   XC$ = MID$(X$,X,1)
  127. 1240   IF "a" <= XC$ AND XC$ <= "z" THEN MID$(X$,X,1) = CHR$(ASC(XC$) - 32)
  128. 1250 NEXT X
  129. 1260 RETURN
  130. 1270 '*********** Subroutine to position at specified line and clear it
  131. 1280 LOCATE PLOC,1
  132. 1290 PRINT STRING$(40," ")'
  133. 1300 LOCATE PLOC,1
  134. 1310 RETURN
  135. 1320 '******************* Subroutine to wait for any keystroke **********
  136. 1330 PRINT "Depress any key to continue... ";
  137. 1340 GOSUB 1360
  138. 1350 RETURN
  139. 1360 '******************* Subroutine to get a keystroke into x$ *********
  140. 1370 X$ = INKEY$
  141. 1380 IF X$ = "" THEN 1370
  142. 1390 RETURN
  143. ******************* Subroutine to get a keystroke into x$ *********
  144. 137