#!/usr/local/rexx/rxx /* * VPTRIM * * VPTRIM is a utility that trims Ventura Publisher markup from a * word processing file. * * Execute the program by typing * * vptrim * * where specifies the input file containing a word processing * file containing Ventura Publisher markup strings and * is one of the uni-REXX TRACE options (all, error, etc.). The * may be ommited. * * The results of running the VPTRIM program are directed to standard * output (the terminal screen) unless redirected to a file. * * Notes: * * Most "@... = " and <...> sequences are simply removed from the * file. * * is changed into three blanks. * * As used at The Workstation Group, this program includes special * treatment for the tagname FUNCTION. The tag text "@FUNCTION" is * discarded; and the text which follows is prepended to the next line * of text in the file, with a dash (-) separating the two portions of * text. This technique could be used for any specific tag name or * could be extended to handle multiple special tags. * * << and >> are translated to < and > respectively. * * Possible enhancements: * * Define our own set of tab stops and try to handle (T) * in a more efficient manner. * * */ parse arg fn traceopt trace value traceopt lag="" do while lines(fn)>0 /* push the entire file through this loop */ line = linein(fn) do while pos("",line)>0 /* turn into white space */ line=overlay(" ",line,pos("",line)) end do while pos("<<",line)>0 /* turn << into x'01' to hide them */ line=left(line,pos("<<",line)-1)||'01'x||, right(line,length(line)-pos("<<",line)-1) end do while pos(">>",line)>0 /* turn >> into x'02' to hide them */ line=left(line,pos(">>",line)-1)||'02'x||, right(line,length(line)-pos(">>",line)-1) end do while pos("<",line)>0 /* take out all other <..anything..> */ if pos(">",line)>0 then line=left(line,pos("<",line)-1)||, right(line,length(line)-pos(">",line)) else do say '********* VPTRIM ERROR: Unmatched "<" in the following line.' leave end end line=translate(line,"<>","0102"x) /* unhide translated << and >> */ if left(line,1)="@" /* check for paragraph tag */ then do type=left(line,10) /* remember tag type */ line = right(line,length(line)-pos("=",line)-1) /* remove it */ if type="@FUNCTION " then do /* for @FUNCTION tag */ lag = line "-" /* save text for next line */ iterate /* and skip putting it out now */ end end say lag line /* put out current line plus any lag data */ lag="" end