-h- unrotate.cmd 711 { unrotate -- unrotate lines rotated by kwic } procedure unrotate; const MAXOUT = 80; MIDDLE = 40; FOLD = DOLLAR; var inbuf, outbuf : string; i, j, f : integer; begin while (getline(inbuf, STDIN, MAXSTR)) do begin for i := 1 to MAXOUT-1 do outbuf[i] := BLANK; f := index(inbuf, FOLD); j := MIDDLE - 1; for i := length(inbuf)-1 downto f+1 do begin outbuf[j] := inbuf[i]; j := j - 1; if (j <= 0) then j := MAXOUT - 1 end; j := MIDDLE + 1; for i := 1 to f-1 do begin outbuf[j] := inbuf[i]; j := j mod (MAXOUT-1) + 1 end; for j := 1 to MAXOUT-1 do if (outbuf[j] <> BLANK) then i := j; outbuf[i+1] := ENDSTR; putstr(outbuf, STDOUT); putc(NEWLINE) end end; -h- unrotate.pas 354 {$debug-} program outer (input,output); {$include:'globcons.inc'} {$include:'globtyps.inc'} {$include:'initio.dcl'} {$include:'flush.dcl' } {$include:'getline.dcl' } {$include:'length.dcl' } {$include:'putstr.dcl' } {$include:'putc.dcl' } {$include:'index.dcl' } {$include:'unrotate.cmd'} BEGIN minitio; initio; unrotate; flush(0); END. -h- unrotate.mak 100 unrotate+initio+getfcb+error+getarg+nargs+flush+ getline+getcf+getc+putc+length+putcf+putstr+ index EGATE = CARET; { ^ } var arg, fromset, toset : string; c : character; i, lastto : 0..MAXSTR; allbut, squash :