home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 19 Printer / 19-Printer.zip / fx80_sty.zip / fx / fx80.us < prev    next >
Text File  |  1995-04-30  |  7KB  |  264 lines

  1. /*********************************************************************
  2.   FX80.cmd
  3.  *********************************************************************
  4.  
  5.    This is the ENGLISH VERSION of FX80.cmd
  6.  
  7.    This is a REXX-Script which can print ASCII-Files in 2 columns, small
  8.    font on an Epson FX80 or compatible.
  9.  
  10.   Supported Printoptions:
  11.     SCR -- Screen, 10 Lines per Page, 30 Characters per column
  12.     FXS -- FX80, 150 Lines per Page, 79 Characters per column, small font
  13.     FXE -- FX80, only 1 column-Spaltig, Font: Elite
  14.  
  15.   You may have to disable the OS/2 print spooler to use this utility.
  16.  
  17.  *********************************************************************
  18.  
  19.   This script is FREEWARE. Usage and Patching for e.g. another printer
  20.   etc. is allowed, as long as this comment is not modified, and my name and
  21.   adress is not cut from this file..
  22.  
  23.   If you make major modifications you wish to share, please email me a
  24.   copy (which a corresponding comment).
  25.  
  26.   My address:  Ralf Grohmann, Winterlinger Weg 8, 70567 Stuttgart, Germany
  27.     or email:   ralf@ubka.uni-karlsruhe.de
  28.  
  29.    (c) Ralf Grohmann 8/93, 1/94
  30.  ******************************************************************** */
  31. ARG DATEI MODE opt1 opt2
  32.  
  33. say '**** ASCII-File - Printer V 1.0                    (c) 1993 Ralf Grohmann ****'
  34.  
  35. IF mode<>'FXS' & mode <>'FXE' & mode<>'SCR' then do
  36.     call help
  37.     EXIT
  38.     END
  39. IF datei='/h' | datei='/?' | datei='-?' | datei='-h' then do
  40.     call help
  41.     EXIT
  42.     END
  43.  
  44. IF lines(datei)=0 then do
  45.     say 'Error: File <' datei '> not found!'
  46.     EXIT
  47.     END
  48.  
  49. /* Parse Options */
  50. pagepause=no
  51. test=no
  52. opt1=left(opt1,2)
  53. opt2=left(opt2,2)
  54. if opt1='/P' | opt2='/P' then pagepause=yes
  55. if opt1='/T' | opt2='/T' then test=yes
  56.  
  57.  
  58.  
  59. /****  Printer-Parms: *****
  60.   initstring : Initialisation-String for the Output-printer (binary Chars)
  61.   sep:         Separator (between the comumns, width 2)
  62.   cret:        Newline (to start a new line)
  63.   ffeed:       FormFeed (send at the end of each page)
  64.   pglen:       Pagelength
  65.   maxzl:       Columnwidth
  66.   pageno:      Starting pagenumber
  67.   protocol:    yes|no (should a Status-Display be generated?)
  68.   dest:        Output-Destination, 'prn:' or 'stdout:' or ...
  69.   dotrans:     yes|no (Should a Character - Transposition (for german Umlauts) be done?
  70.   columns:     Number of columns, 1 or 2
  71. */
  72.  
  73. IF MODE='FXS' THEN DO
  74. /*****  EPSON FX80+ small-mode ********
  75.    Printer Reset, small font, no border.
  76.      ESC @        Reset
  77.      ESC 6        allow Chars > 127
  78.      ESC (15)     Schmalschrift
  79.      ESC M        Elite
  80.      ESC 3 (15)   15/216 inch line spacing
  81.      ESC S 0      Superscript
  82.      ESC Q (160)  right margin
  83. */
  84. initstring='@MS0Qá'
  85. sep='  '
  86. cret = D2C(13) D2C(10)
  87. ffeed = D2C(12)
  88. pglen=150
  89. maxzl=79
  90. pageno=1
  91. protocol=YES
  92. dest='prn:'
  93. dotrans=yes
  94. columns=2
  95. END
  96.  
  97. IF MODE='FXE' THEN DO
  98. /*****  EPSON FX80+ Elite, 1 column ********
  99.    Printer reset,, Elite, left margin 5.
  100.      ESC @        Reset
  101.      ESC 6        allow Chars > 127
  102.      ESC M        Elite
  103.      ESC l (5)    Linker Rand 5
  104.      ESC 0        Zeilenabstand 1/8 Zoll
  105. */
  106. initstring='@Ml'
  107. sep=''
  108. cret = D2C(13) D2C(10)
  109. ffeed = D2C(12)
  110. /* 85 Lines are used for 12" paper */
  111. pglen=85
  112. maxzl=90
  113. pageno=1
  114. protocol=YES
  115. dest='prn:'
  116. dotrans=yes
  117. columns=1
  118. END
  119.  
  120. /***** Preview to Screen ******/
  121. IF mode='SCR' THEN DO
  122. initstring='';
  123. sep='  '
  124. cret = D2C(13) || D2C(10);
  125. ffeed = '************---- NEXT PAGE -----****************'
  126. pglen=10
  127. maxzl=38
  128. pageno=1
  129. protocol=no
  130. dest='stdout:'
  131. dotrans=no
  132. columns=2
  133. END
  134.  
  135.  
  136. /* HeaderString */
  137. if columns=2 then do
  138. hstr='Printing File  <' right(datei,min(length(datei),30)) '> at ' DATE(E)
  139. hstr=left(hstr,maxzl*2-10) '  Page: '
  140. hstr2=right('',maxzl*2+length(sep),'-')
  141. end
  142. else do
  143. hstr='Printing File  <' right(datei,min(length(datei),30)) '> at ' DATE(E)
  144. hstr=left(hstr,maxzl-12) '  Page: '
  145. hstr2=right('',maxzl,'-')
  146. end
  147.  
  148. /* Drucker initialisieren */
  149. r=out(initstring);
  150.  
  151. /***** EINLESEN **********/
  152. i=1
  153. side=0
  154. aktzl=0
  155. DO WHILE lines(datei)
  156.   instring=LINEIN(datei)
  157.   if length(instring)>maxzl then
  158.        in.i.side=LEFT(instring,maxzl-1) || '>'
  159.   else in.i.side=LEFT(instring,maxzl)
  160.   aktzl=aktzl+1
  161.   i=i+1
  162.   IF i=pglen+1 & side=0 THEN DO
  163.           side=1
  164.           if columns=1 then DO
  165.             CALL printside
  166.             side=0
  167.             DROP in.
  168.             END
  169.           i=1
  170.           END
  171.   IF i=pglen+1 & side=1 THEN DO
  172.           CALL printside
  173.           side=0
  174.           i=1
  175.           DROP in.
  176.           END
  177. END /* DO WHILE LINES */
  178.  
  179. /* DEBUG: SAY 'xxxx' i side columns */
  180. if i >= 1 THEN DO
  181.           CALL printside
  182.           DROP in.
  183.           END
  184.  
  185. if test=no then SAY 'File ' datei ' printed (' aktzl ' Lines, ' pageno-1' Page(s) ).'
  186.  else SAY 'File ' datei ' tested (' aktzl ' Lines, ' pageno-1' Page(s) ).'
  187. r=out('')
  188. EXIT
  189.  
  190.  
  191. /*********************************************************************/
  192. /* Prozedur um eine Seite zu drucken */
  193. /* printside: PROCEDURE EXPOSE pglen in. sep cret */
  194. printside:
  195. /* DEBUG say '***** i= ' i ' side= ' side */
  196.  
  197. IF protocol=yes THEN say 'Now printing page ' pageno
  198. r=out(hstr || format(pageno,3) || cret || hstr2 )
  199. pageno=pageno+1
  200. if columns=2 then DO pr_t = 1 TO pglen BY 1
  201.   DROP temp
  202.   IF side=0 & i > pr_t THEN temp=in.pr_t.0 || sep
  203.   IF side=0 & i <= pr_t THEN leave
  204.   IF side=1 & i > pr_t THEN temp=in.pr_t.0 || sep || in.pr_t.1
  205.   IF side=1 & i <= pr_t THEN temp=in.pr_t.0 || sep
  206.   r=out(temp)
  207.  END
  208. ELSE DO pr_t = 1 TO pglen BY 1
  209.  if pr_t < i then r=out(in.pr_t.0)
  210.  END
  211. r=out(ffeed)
  212. if pagepause=yes then do
  213.    say 'Return for next page'
  214.    parse pull arg
  215.    end
  216. RETURN
  217.  
  218. /*********************************************************************/
  219. /* Prozedur zum Ausdrucken
  220.    Ruft evtl. vorher die Zeichenumsetzungsroutine auf */
  221. out:
  222. PARSE ARG string
  223.  
  224. string=TRANSLATE(string,' ',XRANGE('00'x,'1F'x))
  225.  
  226. if dotrans=yes then outstring = deutsch(string) || cret
  227.    else outstring = string || cret
  228. if test=no then do
  229.     res=CHAROUT(dest , outstring )
  230.     if res <> 0 THEN
  231.         SAY 'Error! ' res ' Characters could not be output!'
  232.     END
  233. RETURN 0
  234.  
  235. /*********************************************************************/
  236. /* Setze alle Spezialzeichen um */
  237. /* Recode all special Chars */
  238.  
  239. deutsch: PROCEDURE
  240. parse arg str
  241. /* Syntax Translate(str, to, from) */
  242. str=TRANSLATE(str,'{','ä')
  243. str=TRANSLATE(str,'|','ö')
  244. str=TRANSLATE(str,'}','ü')
  245. str=TRANSLATE(str,'[','Ä')
  246. str=TRANSLATE(str,'\','Ö')
  247. str=TRANSLATE(str,']','Ü')
  248. str=TRANSLATE(str,'~','ß')
  249. RETURN str
  250.  
  251. /*********************************************************************/
  252. /* Hilfe-Ausgabe */
  253. help: PROCEDURE
  254. SAY
  255. SAY 'Usage: fx80 <Name-of-file-to-be-printed> <mode> [opts]'
  256. SAY
  257. SAY 'mode: FXS|FXE|SCR  (Destination)'
  258. SAY '       FXS - Small Font, 2 columns'
  259. SAY '       FXE - 1 column, Elite-Font'
  260. SAY '       SCR - Testoutput to stdout'
  261. SAY 'opts:  /Test - Don''t do the actual output, but test file.'
  262. SAY '       /Pagepause  - Wait after each page printed?'
  263. RETURN
  264.