home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / EPSON / EPSETUP.PAS
Pascal/Delphi Source File  |  1990-05-28  |  13KB  |  361 lines

  1. (14081) Mon 21 May 90 13:45
  2. By: Charles Falconer
  3. To: All (part 1
  4. Re: Epson Printer Setup
  5. St: Sent                                                       Reply in  14082
  6. ------------------------------------------------------------------------------
  7. @MSGID: 1:141/209.1 2658537c
  8. Here is the program that has controlled my printers since about 1983.  I know
  9. there was an earlier version too.  This is an adaptation of the PascalP code.
  10.  
  11. ============= cut (part 1 or 3) EPSETUP.PAS =============
  12. PROGRAM epsetup(lst, input, output);
  13. (* setup Epson RX80 printer *)
  14. (* By C.B. Falconer.  83/Nov/24. Released to Public Domain. *)
  15. (* 1.1 1 Jan 84 - added double strike, elite chars for RX 80 *)
  16. (* 1.2 6 Apr 84 - init does not        cancel double, tabs kept at 8 units *)
  17. (* 1.3 27 Jan 87 - Commands for subscript mode at 13 lpi. *)
  18. (* 1.4 24 Jan 89 - Adapted to TP4 and MSDOS. A second command line *)
  19. (*                 parameter can set the output file *)
  20.  
  21. (* $n-,d- no run-time checks nor line nums. *)
  22.  
  23.   CONST
  24.     header     = 'EPSETUP -commands [prn]';
  25.     copyrite   = 'Ver. 1.4; for MX/RX/FX printers, by C.B. Falconer';
  26.     rx80       = true;     (* false to remove RX80 only commands *)
  27.     cr         = 13;
  28.     ff         = 12;
  29.  
  30.   TYPE
  31.     commands   = (init, setform,
  32.                   compress, elite, pica,
  33.                   normal, double, little,
  34.                   halflf, lpi6, lpi7, lpi8, lpi13,
  35.                   onesheet, multisheet,
  36.                   tabs, formout, none);
  37.                  (* declaration order controls execution order and *)
  38.                  (* thus precedence.  Last declared takes effect *)
  39.  
  40.   VAR
  41.     command    : SET OF commands;
  42.     oneliner   : boolean;
  43.     lst        : text;
  44.     s          : string;
  45.  
  46.   (* 1----------------1 *)
  47.  
  48.   FUNCTION getcommand(VAR s : string) : boolean;
  49.  
  50.     VAR
  51.       cmd        : commands;
  52.       i          : integer;
  53.  
  54.     BEGIN (* getcommand *)
  55.     i := 1;
  56.     IF NOT oneliner THEN BEGIN
  57.       s := '';
  58.       IF rx80 THEN write(
  59. 'I)nit S)etform L)ittle C)ompress E)lite P)ica D)ouble N)ormal ?-')
  60.       ELSE write(
  61. 'I)nit S)etform C)ompress P)ica D)ouble N)ormal ?-');
  62.       readln(s);
  63. {}    WHILE (i < length(s)) AND (s[i] = ' ') DO i := succ(i);
  64.       IF s[i] = '?' THEN BEGIN
  65.         write(
  66. 'O)nepage M)ultipg T)abs H)alflf 6)lpi 7)lpi 8)lpi 9)13lpi F)ormout -');
  67.         readln(s);
  68. {}      WHILE (i < length(s)) AND (s[i] = ' ') DO i := succ(i); END;
  69.       END;
  70.     command := [];
  71.     WHILE (i <= length(s)) AND (s[i] <> ' ') DO BEGIN
  72.       cmd := none; (* also provides for "?" returning here *)
  73.       s[i] := upcase(s[i]);
  74.       CASE s[i] OF
  75.   'C':  cmd := compress;
  76.   'D':  cmd := double;
  77.   'E':  cmd := elite;
  78.   'F':  cmd := formout;
  79.   'H':  cmd := halflf;
  80.   'I':  cmd := init;
  81.   'L':  cmd := little;
  82.   'M':  cmd := multisheet;
  83.   'N':  cmd := normal;
  84.   'O':  cmd := onesheet;
  85.   'P':  cmd := pica;
  86.   'S':  cmd := setform;
  87.   'T':  cmd := tabs;
  88.   '9':  cmd := lpi13;
  89.   '6':  cmd := lpi6;
  90.   '7':  cmd := lpi7;
  91.   '8':  cmd := lpi8;
  92. (*$s- non-standard Pascal *)
  93.       ELSE (* ignore *);
  94. (*$s+*) END; (* case *)
  95.       command := command + [cmd]; i := succ(i); END;
  96.     getcommand := command <> [];
  97.     END; (* getcommand *)
  98.  
  99.   (* 1----------------1 *)
  100. ============== cut (part 2 continues) ==============
  101.  
  102. --- msged 1.999.6
  103. @SEEN-BY 241/1 2 242/20 244/1 280/0 310/11 500/206 507/1 13 414 440
  104. @SEEN-BY 512/0 1 4 9 11 15 23 26 27 29 32 33 99 102 124 1006 1007
  105. @SEEN-BY 515/1
  106. @PATH: 30185/1 141/888 322/1 13/13 260/330 340 310/11 507/1 512/0
  107.  * Origin: Ched Consultants, Hamden CT. voice 203-281-1438  (1:141/209.1)
  108.  
  109.  
  110. ------------------------------------------------------------------------------
  111. (14082) Mon 21 May 90 13:48
  112. By: Charles Falconer
  113. To: All (part 2
  114. Re: Epson Printer Setup
  115. St: Sent                                              Reply chain 14081  14083
  116. ------------------------------------------------------------------------------
  117. @MSGID: 1:141/209.1 26585474
  118. 'overprint' procedure has been replaced by a specific <cr> in the output
  119. strings to the printer (for TP).
  120.  
  121. =========== cut (part 2 of 3) EPSETUP.PAS =========
  122.   PROCEDURE setup(verbose : boolean);
  123.   (* The overprint procedure suppresses a final line-feed, *)
  124.   (* but flushes buffers with a final carriage return.     *)
  125.   (* Prompt flushes buffers with no cr nor lf.             *)
  126.  
  127.     CONST
  128. (* $s- these character definitions are non-standard Pascal *)
  129.       si       = #15;
  130.       dc1      = #17;
  131.       dc2      = #18;
  132.       dc3      = #19;
  133.       dc4      = #20;
  134.       esc      = #27;
  135. (* $s+*)
  136.  
  137.     VAR
  138.       cmd      : commands;
  139.  
  140.     BEGIN (* setup *)
  141.     command := command - [none]; (* ensure empty *)
  142.     cmd := init;
  143.     WHILE cmd < none DO BEGIN (* scan in declared order *)
  144.       IF cmd IN command THEN BEGIN
  145.         write(lst, dc1 {enable}, dc1 {flush any garbage});
  146.         CASE cmd OF
  147. init:     BEGIN
  148.           command := command + [setform, multisheet, compress, normal];
  149.           IF verbose THEN
  150.             writeln('Initializing for 11 inch page, 3 line skipover');
  151.           write(lst, dc2, {cancel condensed chars}
  152.                      dc4, {cancel enlarged chars}
  153.                      esc, '2', {std line spacing via dip switch}
  154.                      esc, 'F', {cancel emphasized printing}
  155.                      esc, 'T', {cancel any subscript mode}
  156.                      chr(cr)   {terminate line}
  157.                 );  (* pagesize setting sets top of form *)
  158.           END;
  159. halflf:
  160.           BEGIN
  161.           IF verbose THEN writeln('Setting 1/2 line feed @ 6 lpi');
  162.           write(lst, esc, 'A', chr(6) {72nds inch/line}, chr(cr));
  163.           END;
  164. lpi6:
  165.           BEGIN
  166.           IF verbose THEN writeln('Setting 6 lines/in, 63 per page');
  167.           write(lst, esc, 'A', chr(12) {72nds inch/line}, chr(cr));
  168.           END;
  169. lpi7:
  170.           BEGIN
  171.           IF verbose THEN writeln('Setting 7 lines/in, 76 per page');
  172.           write(lst, esc, 'A', chr(10) {72nds inch/line}, chr(cr));
  173.           END;
  174. lpi8:
  175.           BEGIN
  176.           IF verbose THEN writeln('Setting 8 lines/in, 84 per page');
  177.           write(lst, esc, 'A', chr(9) {72nds inch/line}, chr(cr));
  178.           END;
  179. lpi13:
  180.           BEGIN
  181.           IF verbose THEN writeln('Setting 13 lines/in, 142 per page');
  182.           write(lst, esc, '3', chr(16) {216ths inch/line}, chr(cr));
  183.           END;
  184. onesheet:
  185.           BEGIN
  186.           IF verbose THEN writeln('No paper-out detection');
  187.           write(lst, esc, '8', chr(cr));
  188.           END;
  189. multisheet:
  190.           BEGIN
  191.           IF verbose THEN writeln('Paper-out detection');
  192.           write(lst, esc, '9', chr(cr));
  193.           END;
  194. setform:
  195.           BEGIN
  196.           IF verbose THEN BEGIN
  197.             write('Position paper to top of form, press return');
  198.             readln; END;
  199.           write(lst, esc, 'C', chr(0), chr(11) {inch pages}
  200.                     ,esc, 'N', chr(3)   {lines skipover}
  201.                     ,chr(cr)
  202.                 ); (* pagesize setting sets top of form *)
  203.           END;
  204. little:   BEGIN
  205.           IF rx80 THEN BEGIN
  206.             IF verbose THEN writeln('Setting subscript font');
  207.             write(lst, esc, 'S', chr(1), chr(cr)); {set subscript} END;
  208.           END;
  209. elite:
  210.           BEGIN
  211.           IF rx80 THEN BEGIN
  212.             IF verbose THEN writeln('Setting 96 char. lines');
  213.             write(lst, esc ,'M' {set elite chars}
  214.                      , esc ,'T' {cancel any subscript}
  215.                      , chr(cr)
  216.                   );
  217.             command := command + [tabs]; END;
  218.           END;
  219. ========= cut (continues on part 3) ==============
  220.  
  221. --- msged 1.999.6
  222. @SEEN-BY 241/1 2 242/20 244/1 280/0 310/11 500/206 507/1 13 414 440
  223. @SEEN-BY 512/0 1 4 9 11 15 23 26 27 29 32 33 99 102 124 1006 1007
  224. @SEEN-BY 515/1
  225. @PATH: 30185/1 141/888 322/1 13/13 260/330 340 310/11 507/1 512/0
  226.  * Origin: Ched Consultants, Hamden CT. voice 203-281-1438  (1:141/209.1)
  227.  
  228.  
  229. ------------------------------------------------------------------------------
  230. (14083) Mon 21 May 90 13:51
  231. By: Charles Falconer
  232. To: All (part 3
  233. Re: Epson Printer Setup
  234. St: Sent                                              Reply chain 14082  14084
  235. ------------------------------------------------------------------------------
  236. @MSGID: 1:141/209.1 265854ca
  237. =========== cut (part 3) EPSETUP.PAS =========
  238. compress:
  239.           BEGIN
  240.           IF verbose THEN writeln('Setting 132 char. lines');
  241.           IF rx80 THEN write(lst ,esc ,'P'  {cancel elite chars}
  242.                                  ,esc ,'T'  {cancel subscript}
  243.                             );
  244.           write(lst, si, chr(cr)); command := command + [tabs];
  245.           END;
  246. pica:
  247.           BEGIN
  248.           IF verbose THEN writeln('Setting 80 char. lines');
  249.           IF rx80 THEN write(lst, esc, 'P' {cancel elite chars}
  250.                                  ,esc ,'T' {cancel subscript}
  251.                             );
  252.           write(lst ,dc2      {cancel condensed chars}
  253.                     ,dc4      {cancel enlarged chars}
  254.                     ,esc ,'F' {cancel emphasised print}
  255.                     ,chr(cr)
  256.                 );
  257.           command := command + [tabs];
  258.           END;
  259. tabs:
  260.           BEGIN
  261.           IF rx80 THEN BEGIN
  262.             IF verbose THEN writeln('Setting tabs at 8 char interval');
  263.             write(lst, esc ,'e0', chr(8) {keep tabs aligned}, chr(cr)); END;
  264.           END;
  265. double:
  266.           BEGIN
  267.           IF verbose THEN
  268.             writeln('Setting double strike (letter) mode');
  269.           write(lst, esc, 'G', chr(cr));
  270.           END;
  271. normal:
  272.           BEGIN
  273.           IF verbose THEN
  274.             writeln('Cancelling double strike (letter) mode');
  275.           write(lst, esc, 'H', chr(cr));
  276.           END;
  277. formout:
  278.           BEGIN
  279.           IF verbose THEN writeln('Advancing to top of page');
  280.           write(lst, chr(ff));
  281.           END;
  282.  
  283.           END; (* case *)
  284.         END;
  285.       command := command - [cmd]; cmd := succ(cmd); END;
  286.     END; (* setup *)
  287.  
  288.   (* 1----------------1 *)
  289.  
  290.   PROCEDURE checkfor(VAR oneliner : boolean);
  291.  
  292.     BEGIN (* checkfor *)
  293.     oneliner := false; (* default *)
  294.     IF paramcount > 1 THEN assign(lst, paramstr(2));
  295.     IF paramcount > 0 THEN BEGIN
  296.       s := paramstr(1);
  297.       IF s[1] = '-' THEN oneliner := true
  298.       ELSE assign(lst, s); END;
  299.     END; (* checkfor *)
  300.  
  301.   (* 1----------------1 *)
  302.  
  303.   BEGIN (* epsetup *)
  304.   assign(lst, 'PRN');
  305.   checkfor(oneliner);
  306. {$i-}
  307.   rewrite(lst); {$i+}
  308.   IF ioresult <> 0 THEN BEGIN
  309.     writeln('Can''t open printer file. Use EPSETUP alone for help');
  310.     halt; END;
  311.   IF oneliner THEN BEGIN
  312.     IF getcommand(s) THEN setup(false); END
  313.   ELSE BEGIN
  314.     writeln(header); writeln(copyrite); writeln;
  315.     writeln('Options may be entered after "-" in command line');
  316.     writeln('  Ex: A>epsetup -ed   (for elite double-strike)');
  317.     writeln('Multiple letters in one command cause multiple actions');
  318.     writeln('    ''?'' shows extended commands');
  319.     WHILE getcommand(s) DO
  320.       WHILE command <> [] DO setup(true); END;
  321.   close(lst);
  322.   END. (* epsetup *)
  323. ========== cut (the end) ==========
  324.  
  325. --- msged 1.999.6
  326. @SEEN-BY 241/1 2 242/20 244/1 280/0 310/11 500/206 507/1 13 414 440
  327. @SEEN-BY 512/0 1 4 9 11 15 23 26 27 29 32 33 99 102 124 1006 1007
  328. @SEEN-BY 515/1
  329. @PATH: 30185/1 141/888 322/1 13/13 260/330 340 310/11 507/1 512/0
  330.  * Origin: Ched Consultants, Hamden CT. voice 203-281-1438  (1:141/209.1)
  331.  
  332.  
  333. ------------------------------------------------------------------------------
  334. (14084) Mon 21 May 90 14:34
  335. By: Charles Falconer
  336. To: All (conclusion)
  337. Re: Epson Printer Setup
  338. St: Sent                                                       Reply to 14083
  339. ------------------------------------------------------------------------------
  340. @MSGID: 1:141/209.1 26585fc4
  341. This code can run on many systems, with minimal changes.  It is command line or
  342. interactively driven, so it is useful in batch files and such.
  343.  
  344. My normal printer configuration is set with "EPSETUP -ie8", which gives me over
  345. 80 lines per page at 96 columns, on 11 inch forms.  Europeans will probably
  346. want to make some small changes for 12 inch forms.  Note that, on the RX80 up,
  347. the tab interval is corrected to agree with the font, and that the skip over
  348. perforation is set to 1/2 inch, or 3 lines at 6 lpi.
  349.  
  350. It does NOT test for printer availability, so you can get an apparent hang.
  351.  
  352. A questionmark at the prompt yields the second prompt line.
  353.  
  354. --- msged 1.999.6
  355. @SEEN-BY 241/1 2 242/20 244/1 280/0 310/11 500/206 507/1 13 414 440
  356. @SEEN-BY 512/0 1 4 9 11 15 23 26 27 29 32 33 99 102 124 1006 1007
  357. @SEEN-BY 515/1
  358. @PATH: 30185/1 141/888 322/1 13/13 260/330 340 310/11 507/1 512/0
  359.  * Origin: Ched Consultants, Hamden CT. voice 203-281-1438  (1:141/209.1)
  360.  
  361.