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

  1. -h- kwic.cmd 189
  2. { kwic -- make keyword in context index }
  3. procedure kwic;
  4. const
  5.  FOLD = DOLLAR;
  6. var
  7.  buf : string;
  8. {$include:'putrot.kwi'}
  9. begin
  10.  while (getline(buf, STDIN, MAXSTR)) do
  11.   putrot(buf)
  12. end;
  13.  
  14. -h- kwic.pas 298
  15. {$debug-}
  16. program outer (input,output);
  17.  
  18. {$include:'globcons.inc'}
  19. {$include:'globtyps.inc'}
  20.  
  21. {$include:'initio.dcl'}
  22. {$include:'flush.dcl' }
  23.  
  24. {$include:'getline.dcl' }
  25. {$include:'isalphan.dcl'}
  26. {$include:'putc.dcl'    }
  27.  
  28. {$include:'kwic.cmd'    }
  29. BEGIN
  30.   minitio; initio;
  31.   kwic;
  32.   flush(0);
  33. END.
  34. -h- kwic.mak 84
  35. kwic+initio+getfcb+error+getarg+nargs+flush+
  36. getline+getcf+getc+putc+isalphan+putcf
  37. -h- putrot.kwi 372
  38. { putrot -- create lines with keyword at front }
  39. procedure putrot (var buf : string);
  40. var
  41.  i : integer;
  42. {$include:'rotate.kwi'}
  43. begin
  44.  i := 1;
  45.  while (buf[i] <> NEWLINE) and (buf[i] <> ENDSTR) do begin
  46.   if (isalphanum(buf[i])) then begin
  47.    rotate(buf, i); { token starts at "i" }
  48.    repeat
  49.     i := i + 1
  50.    until (not isalphanum(buf[i]))
  51.   end;
  52.   i := i + 1
  53.  end
  54. end;
  55.  
  56. -h- rotate.kwi 283
  57. { rotate -- output rotated line }
  58. procedure rotate (var buf : string; n : integer);
  59. var
  60.  i : integer;
  61. begin
  62.  i := n;
  63.  while (buf[i] <> NEWLINE) and (buf[i] <> ENDSTR) do begin
  64.   putc(buf[i]);
  65.   i := i + 1
  66.  end;
  67.  putc(FOLD);
  68.  for i := 1 to n-1 do
  69.   putc(buf[i]);
  70.  putc(NEWLINE)
  71. end;
  72.  
  73.