[comp.binaries.ibm.pc.d] Trying to chop long PS lines

) (10/23/90)

Does anyone know of an utility which would wrap very long lines in a file?
I'm using Aldus PageMaker to create postscript files which I would upload to
the VAX.  Unfortunately, whenever I have a large number of graphics, the lines
become VERY long.  VAX can't read these long lines.  I've downloaded 
WRAPLIN2.ARC from Simtel20, but I found a very significant error.  On a lot of
the lines, the first character of each original line is not written to the new
file.  I would appreciate any help which I can get.
-- 

-------------------------------------------------------------------------------
 Santanu Sircar                                BITNET:   ssircar@umaecs.bitnet
 University of Massachusetts/Amherst           INTERNET: ssircar@ecs.umass.edu
|------------------------------------------------------------------------------|
 "A pig ate his fill of acorns under an oak tree and then started to root
   around the tree.  A crow remarked, `You should not do this.  If you lay bare
   the roots, the tree will wither and die.' `Let it die,' said the pig.  `Who
   cares so long as there are acorns?'"	-"Animal Farm" by George Orwell
 ------------------------------------------------------------------------------

) (10/23/90)

In article <11144.27239e63@ecs.umass.edu>, ssircar@ecs.umass.edu (Good writers re-write -- not write!) writes:
> Does anyone know of an utility which would wrap very long lines in a file?
> I'm using Aldus PageMaker to create postscript files which I would upload to
> the VAX.  Unfortunately, whenever I have a large number of graphics, the lines
> become VERY long.  VAX can't read these long lines.  I've downloaded 
> WRAPLIN2.ARC from Simtel20, but I found a very significant error.  On a lot of
> the lines, the first character of each original line is not written to the new
> file.  I would appreciate any help which I can get.
I forgot to mention that it is a VAX/VMS.
-- 

-------------------------------------------------------------------------------
 Santanu Sircar                                BITNET:   ssircar@umaecs.bitnet
 University of Massachusetts/Amherst           INTERNET: ssircar@ecs.umass.edu
|------------------------------------------------------------------------------|
 "A pig ate his fill of acorns under an oak tree and then started to root
  around the tree.  A crow remarked, `You should not do this.  If you lay bare
  the roots, the tree will wither and die.' `Let it die,' said the pig.  `Who
  cares so long as there are acorns?'"	-"Animal Farm" by George Orwell
 ------------------------------------------------------------------------------

toms@fcs260c2.ncifcrf.gov (Tom Schneider) (10/23/90)

In article <11144.27239e63@ecs.umass.edu> ssircar@ecs.umass.edu
(Santanu sircar) writes:
>Does anyone know of an utility which would wrap very long lines in a file?

It seems that in these modern times people still insist on making long file
lines.  The output of the f2ps program (which converts the fig program;s
graphics to PostScript) is long lines, and these cause my LaserWriter ntxII to
die.  The general rule is to avoid lines being longer than 80 characers.
Following is a filter, written in Pascal, that wraps lines between words that
should work for you.  It should compile on a VAX.

> Santanu Sircar                                BITNET:   ssircar@umaecs.bitnet
> University of Massachusetts/Amherst           INTERNET: ssircar@ecs.umass.edu

  Tom Schneider
  National Cancer Institute
  Laboratory of Mathematical Biology
  Frederick, Maryland  21702-1201
  toms@ncifcrf.gov
- snip - snip - snip - snip - snip - snip - snip - snip - snip - snip - snip 
program ww(input,output);
(* ww: word wrap 
   Tom Schneider, 1988 *)

const
(* begin module version *)
version = 1.01; (* of ww 1988 September 14
origin 1988 aug 22 *)
(* end module version *)

(* begin module describe.ww *)
(*
name
   ww: word wrap 

synopsis
   ww(input: in, output: out)

files
   input:  text to be wrapped
   output: wrapped text

description
   This Pascal program takes ASCII text and filters it.  Lines longer than the
constant maxline are altered by replacing the first space after position
maxline with a carriage return.  This has the effect of wrapping the lines
between 'words'.
   The original purpose was to get around a design flaw in another program.
The program fig produces graphics for X and NeWS windows.  The graphics
is converted to PostScript by another program, f2ps.  Unfortunately f2ps
was poorly designed: the PostScript produced has many lines longer than
70 characters.  When this PostScript code is sent to the (latest as
of 1988) Apple NTX LaserWriterII, the printer dies.  By running this filter,
the problem is bypassed.  Moral: never make lines longer than 80 characters!

author
   Thomas Dana Schneider

bugs
   the constant maxline is fixed at compile time, of course.

*)
(* end module describe.ww *)

    maxline = 70; (* maximum width of output lines *)

var c: char; (* a character in the input *)
    n: integer; (* number of characters written to output so far *)
    waitforspace: boolean; (* true if waiting for the next space to appear *)
begin
  while not eof(input) do begin
    n := 0; (* no characters written out so far on this line *)
    waitforspace := false;
    while not eoln(input) do begin
      read(input,c);
      if n > maxline then waitforspace := true;

      if waitforspace and (c = ' ')
      then begin 
         writeln(output); (* replace space with carriage return *)
         n := 0; (* no characters written out so far on this line *)
         waitforspace := false;
      end
      else begin
        write(output,c);
        n := n + 1;
      end
    end;

    readln(input);
    writeln(output);
  end
end.