/* Filter a portion of text through a unix command. From: Ian Collier Date: Thu, 11 Dec 1997 21:15:54 +0000 Syntax: filter target command Filters the region from the current line to the target. If the Unix command returns a non-zero rc then the original text will be restored. Up to 5 lines of error output will be written to the THE message line. example: filter 5 fmt -72 format the next 5 lines of text with Unix "fmt" utility */ trace o parse arg target command delim='/' if left(target,1)==delim then do parse arg (delim) target (delim) command target=delim || target || delim end if command='' then do "COMMAND EMSG Missing parameter" exit 1 end "COMMAND EXTRACT/LINEND/LINE/ALT" start=line.1 "COMMAND LOCATE" target if rc\=0 then exit rc "COMMAND EXTRACT/LINE" if line.15 then error.0=5 "COMMAND LINEND OFF" do i=1 to error.0 "COMMAND EMSG" error.i end if retcode\=0 then "COMMAND EMSG Command returned rc" retcode if (retcode\=0 | error.0>0) & output.0=0 then "COMMAND RECOVER" input.0 else do i=1 to output.0 "INPUT" output.i end "COMMAND :"start "COMMAND SET ALT" alt.1+1 alt.2+1 "COMMAND SET LINEND" linend.1 exit retcode