home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / PASCAL / PT03.ZIP / UNROTATE.AR < prev    next >
Encoding:
Text File  |  1983-09-06  |  1.3 KB  |  62 lines

  1. -h- unrotate.cmd 711
  2. { unrotate -- unrotate lines rotated by kwic }
  3. procedure unrotate;
  4. const
  5.  MAXOUT = 80;
  6.  MIDDLE = 40;
  7.  FOLD = DOLLAR;
  8. var
  9.  inbuf, outbuf : string;
  10.  i, j, f : integer;
  11. begin
  12.  while (getline(inbuf, STDIN, MAXSTR)) do begin
  13.   for i := 1 to MAXOUT-1 do
  14.    outbuf[i] := BLANK;
  15.   f := index(inbuf, FOLD);
  16.   j := MIDDLE - 1;
  17.   for i := length(inbuf)-1 downto f+1 do begin
  18.    outbuf[j] := inbuf[i];
  19.    j := j - 1;
  20.    if (j <= 0) then
  21.     j := MAXOUT - 1
  22.   end;
  23.   j := MIDDLE + 1;
  24.   for i := 1 to f-1 do begin
  25.    outbuf[j] := inbuf[i];
  26.    j := j mod (MAXOUT-1) + 1
  27.   end;
  28.   for j := 1 to MAXOUT-1 do
  29.    if (outbuf[j] <> BLANK) then
  30.     i := j;
  31.   outbuf[i+1] := ENDSTR;
  32.   putstr(outbuf, STDOUT);
  33.   putc(NEWLINE)
  34.  end
  35. end;
  36. -h- unrotate.pas 354
  37. {$debug-}
  38. program outer (input,output);
  39.  
  40. {$include:'globcons.inc'}
  41. {$include:'globtyps.inc'}
  42.  
  43. {$include:'initio.dcl'}
  44. {$include:'flush.dcl' }
  45.  
  46. {$include:'getline.dcl' }
  47. {$include:'length.dcl'  }
  48. {$include:'putstr.dcl'  }
  49. {$include:'putc.dcl'    }
  50. {$include:'index.dcl'   }
  51.  
  52. {$include:'unrotate.cmd'}
  53. BEGIN
  54.   minitio; initio;
  55.   unrotate;
  56.   flush(0);
  57. END.
  58. -h- unrotate.mak 100
  59. unrotate+initio+getfcb+error+getarg+nargs+flush+
  60. getline+getcf+getc+putc+length+putcf+putstr+
  61. index
  62.