home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
XL2PS.CMD
/
XL2PS.CMD
Wrap
OS/2 REXX Batch file
|
1992-11-26
|
10KB
|
265 lines
/* XL2PS.CMD 2.0 30-Aug-1992
*
* Convert Excelerator screen interface file to a postscript
* image, suitable for using in VAX Document
*
* The image produced is appropriate for the Software.Reference
* doctype, with a figure height of 15 for an informal figure.
*
* V2.0 920830 JJM - Change to accept PC line drawing characters
* and convert them to graphical lines so that
* VAX Document ASCII encoding doesn't mess it up.
*/
ARG FileArg
/* Name of the output file, for now, force to stdout */
Outfile =FileArg || '.PS'
/* Name of the input file, again, fixed for now */
Infile = FileArg || '.SCI'
Y1 = 0
Y2 = 0
Blanks = ' '
/* Output the stuff that belongs at the beginning of the Postscript */
Nn = LINEOUT( Outfile, '%!PS_Adobe 2.0')
Nn = LINEOUT( Outfile, '%%Title: ' || Infile )
Nn = LINEOUT( Outfile, '%%Creator: XL2PS.Cmd 2.0')
Nn = LINEOUT( Outfile, '%%CreationDate: '||DATE('N') TIME('C'))
Nn = LINEOUT( Outfile, '%%DocumentProcSets: XLSCR')
Nn = LINEOUT( Outfile, '%%DocumentSuppliedProcSets: XLSCR')
Nn = LINEOUT( Outfile, '%%EndComments')
Nn = LINEOUT( Outfile, '%%BeginProcSet: XLSCR')
/* Set up a buncha macros that simply allow us to have a slightly
* shorter PostScript output */
Nn = LINEOUT( Outfile, '/B {bind def} bind def')
Nn = LINEOUT( Outfile, '/m { moveto } B /l { lineto } B /t { show } B')
Nn = LINEOUT( Outfile, '/w { setlinewidth } B /n { newpath } B /s { stroke } B')
Nn = LINEOUT( Outfile, '/c { findfont 30 scalefont setfont } B')
Nn = LINEOUT( Outfile, '/g { setgray } B /f { fill } B /sm {setmatrix} B')
Nn = LINEOUT( Outfile, '/mx {matrix} B /cm {currentmatrix} B')
Nn = LINEOUT( Outfile, '/md mx cm def /setmx {md sm concat} B')
Nn = LINEOUT( Outfile, '%%EndProcSet')
Nn = LINEOUT( Outfile, '%%EndProlog')
/* Now do the stuff that scales the image */
Nn = LINEOUT( Outfile, 'gsave')
Nn = LINEOUT( Outfile, 'initgraphics')
/* The following line is omitted only for inclusion in Document */
/* Uncomment the line if you want to print the result directly */
/* Comment the line for inclusion in Document or other text processors */
Nn = LINEOUT( Outfile, '100 300 translate')
Nn = LINEOUT( Outfile, '.24 .24 scale')
Nn = LINEOUT( Outfile, '1.0 w')
/* The first two lines of the Excelerator interface file
* aren't real interesting for now. */
HeaderLine = LINEIN( Infile )
TitleLine = LINEIN( Infile )
/* Begin reading the real stuff, continue until out of file */
Line1 = 'xxx'
DO UNTIL Line1 = ''
Line1 = ''
Line1 = LINEIN(InFile)
IF Line1 == '' THEN LEAVE
/* The first line of all fields describes the field */
Y1 = SUBSTR(Line1,1,2) /* Column of field */
X1 = SUBSTR(Line1,3,3) /* Row of field */
FieldType = SUBSTR(Line1,6,1) /* Type of field */
/* OK, We'll go do all field types */
if FieldType \= '?' THEN DO
/* Get the default contents, strip trailing blanks */
RawCont = STRIP(LINEIN(InFile),'T',' ')
FldCont = RawCont;
/* Search for line-drawing characters in the string */
LineDraws = 0
/* Now replace line drawing characters in the field with
* blanks and make another vector containing only the
* line drawing characters */
LineStr = SUBSTR(Blanks,1,LENGTH(RawCont))
DO I=1 TO LENGTH(RawCont)
IF SUBSTR(RawCont,I,1) > D2C(127) THEN DO
LineDraws = 1
FldCont = OVERLAY(' ',FldCont,I)
LineStr = OVERLAY(SUBSTR(RawCont,I,1),LineStr,I)
END
END
/* If it's an input field, there's 3 extra lines
* we really don't care about for now. */
IF FieldType = 'I' THEN DO
Dummy=LINEIN(InFile)
Dummy=LINEIN(InFile)
Dummy=LINEIN(InFile)
END
IF FieldType = 'O' THEN DO
Dummy=LINEIN(InFile)
END
/* Calculate where on the page this field starts */
Y2 = (25-Y1) * 30 - 10
X2 = TRUNC(X1 * 18 + .5 )
/* Use Courier, unless it's bright, then use bold */
charset = '/Courier'
/* If column 12 is a Y, the field is bold */
if ( SUBSTR(Line1,12,1) ) = 'Y' THEN
charset = '/Courier-Bold'
/* If it's a reverse-video, we have work to do */
/* If column 13 is a Y, the field is reverse */
if ( SUBSTR(Line1,13,1) ) = 'Y' THEN DO
/* Non-bold really aren-t visible */
charset = '/Courier-Bold'
/* Calculate the boundaries of the box */
Left = X2-2
Right = X2 + LENGTH(FldCont) * 18 + 2
Top = Y2 + 23
Bottom = Y2 - 7
/* Now draw a black box where the letters belong */
Outline1 = '0 g n' Left Bottom 'm' Right Bottom 'l'
Outline1 = Outline1 Right Top 'l' Left Top 'l'
Outline1 = Outline1 Left Bottom 'l'
Nn = LINEOUT(Outfile, Outline1 )
/* Fill the box and set the character color to white */
Nn = LINEOUT(Outfile, 'fill 1 g')
/* Output the characters */
OutLine = charset 'c' X2 Y2 'm ('|| FldCont||') t'
Nn = LINEOUT( Outfile, OutLine )
/* Set the character color back to black */
Nn= LINEOUT( Outfile, '0 g' )
END
ELSE DO
/* Not reverse video, output the sharacters */
OutLine1 = charset 'c' X2 Y2 'm ('|| FldCont||') t'
Nn = LINEOUT( Outfile, OutLine1 )
END
/* Process underlined fields by drawing a line */
/* If column 15 is a Y, the field is underlined */
if ( SUBSTR(Line1,15,1) ) = 'Y' THEN DO
Left = X2-4
Right = X2 + LENGTH(FldCont) * 18 + 4
Bottom = Y2 - 7
Outline1 = '1.0 w n' Left Bottom 'm' Right Bottom 'l s'
Nn = LINEOUT( Outfile, OutLine1 )
END
END
/* Now it gets really gross -- for each line drawing character
* (actually, only the single-line ones are handled) we actually
* *DRAW* the character using vectors. This is necessary since
* DEC screws up the character encoding vectors in VAX Document
* so the the normal line-drawing characters aren't available */
IF LineDraws = 1 THEN DO
DO I=1 TO LENGTH(LineSTR)
X2 = TRUNC((X1+I-1) * 18 + .5 )
SELECT
WHEN SUBSTR(LineStr,I,1) = '─' THEN DO
OutLine1 = X2||' '||Y2+15||' m '
OutLine1 = OutLine1 || X2+18 || ' ' || Y2+15
OutLine1 = OutLine1 || ' l s'
Nn = LINEOUT( Outfile, OutLine1 )
END
WHEN SUBSTR(LineStr,I,1) = '│' THEN DO
OutLine1 = X2+9||' '||Y2+30||' m '
OutLine1 = OutLine1 || X2+9 || ' ' || Y2
OutLine1 = OutLine1 || ' l s'
Nn = LINEOUT( Outfile, OutLine1 )
END
WHEN SUBSTR(LineStr,I,1) = '┌' THEN DO
OutLine1 = X2+9||' '||Y2||' m '
OutLine1 = OutLine1 || X2+9||' '||Y2+15||' l '
OutLine1 = OutLine1 || X2+18 || ' ' || Y2+15
OutLine1 = OutLine1 || ' l s'
Nn = LINEOUT( Outfile, OutLine1 )
END
WHEN SUBSTR(LineStr,I,1) = '┐' THEN DO
OutLine1 = X2+9||' '||Y2||' m '
OutLine1 = OutLine1 || X2+9||' '||Y2+15||' l '
OutLine1 = OutLine1 || X2 || ' ' || Y2+15
OutLine1 = OutLine1 || ' l s'
Nn = LINEOUT( Outfile, OutLine1 )
END
WHEN SUBSTR(LineStr,I,1) = '└' THEN DO
OutLine1 = X2+9||' '||Y2+30||' m '
OutLine1 = OutLine1 || X2+9||' '||Y2+15||' l '
OutLine1 = OutLine1 || X2+18 || ' ' || Y2+15
OutLine1 = OutLine1 || ' l s'
Nn = LINEOUT( Outfile, OutLine1 )
END
WHEN SUBSTR(LineStr,I,1) = '┘' THEN DO
OutLine1 = X2||' '||Y2+15||' m '
OutLine1 = OutLine1 || X2+9||' '||Y2+15||' l '
OutLine1 = OutLine1 || X2+9 || ' ' || Y2+30
OutLine1 = OutLine1 || ' l s'
Nn = LINEOUT( Outfile, OutLine1 )
END
WHEN SUBSTR(LineStr,I,1) = '├' THEN DO
OutLine1 = X2+9||' '||Y2+30||' m '
OutLine1 = OutLine1 || X2+9 || ' ' || Y2
OutLine1 = OutLine1 || ' l s '
OutLine1 = OutLine1 || X2+9||' '||Y2+15||' m '
OutLine1 = OutLine1 || X2+18 || ' ' || Y2+15
OutLine1 = OutLine1 || ' l s'
Nn = LINEOUT( Outfile, OutLine1 )
Nn = LINEOUT( Outfile, OutLine1 )
END
WHEN SUBSTR(LineStr,I,1) = '┤' THEN DO
OutLine1 = X2+9||' '||Y2+30||' m '
OutLine1 = OutLine1 || X2+9 || ' ' || Y2
OutLine1 = OutLine1 || ' l s '
OutLine1 = OutLine1 || X2||' '||Y2+15||' m '
OutLine1 = OutLine1 || X2+9 || ' ' || Y2+15
OutLine1 = OutLine1 || ' l s'
Nn = LINEOUT( Outfile, OutLine1 )
Nn = LINEOUT( Outfile, OutLine1 )
END
WHEN SUBSTR(LineStr,I,1) = '┬' THEN DO
OutLine1 = X2||' '||Y2+15||' m '
OutLine1 = OutLine1 || X2+18 || ' ' || Y2+15
OutLine1 = OutLine1 || ' l s '
OutLine1 = OutLine1 || X2+9||' '||Y2+15||' m '
OutLine1 = OutLine1 || X2+9 || ' ' || Y2
OutLine1 = OutLine1 || ' l s'
Nn = LINEOUT( Outfile, OutLine1 )
END
WHEN SUBSTR(LineStr,I,1) = '┴' THEN DO
OutLine1 = X2||' '||Y2+15||' m '
OutLine1 = OutLine1 || X2+18 || ' ' || Y2+15
OutLine1 = OutLine1 || ' l s '
OutLine1 = OutLine1 || X2+9||' '||Y2+15||' m '
OutLine1 = OutLine1 || X2+9 || ' ' || Y2+30
OutLine1 = OutLine1 || ' l s'
Nn = LINEOUT( Outfile, OutLine1 )
END
WHEN SUBSTR(LineStr,I,1) = '┼' THEN DO
OutLine1 = X2||' '||Y2+15||' m '
OutLine1 = OutLine1 || X2+18 || ' ' || Y2+15
OutLine1 = OutLine1 || ' l s '
OutLine1 = OutLine1 || X2+9||' '||Y2+30||' m '
OutLine1 = OutLine1 || X2+9 || ' ' || Y2
OutLine1 = OutLine1 || ' l s'
Nn = LINEOUT( Outfile, OutLine1 )
END
OTHERWISE
; /* It's a character we don't recognize */
END
END
END
END
/* Draw a box around the screen area */
Nn = LINEOUT( Outfile, '3.0 w n')
Nn = LINEOUT( Outfile, '0 0 m 0 750 l 1466 750 l 1466 0 l 0 0 l s')
/* Finally, tell the printer we really would like to see this */
Nn = LINEOUT( Outfile, 'grestore')
Nn = LINEOUT( Outfile, 'showpage')
Nn = LINEOUT( Outfile, '%!')