home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-02-08 | 1.9 KB | 99 lines | [TEXT/PJMM] |
- unit LOOKUP;
-
- interface
-
- uses
- ParameterDef;
-
- procedure Main (var p: parameterRecord);
-
- implementation
-
- const
- cr = chr(13);
- spc = ' ';
-
- procedure Main (var p: parameterRecord);
- var
- rn: integer;
- count, len: longInt;
- s, t: str255;
- function MyFSFill: OSErr;
- var
- l: longInt;
- oe: OSErr;
- begin
- l := 254 - len;
- if l > count then
- l := count;
- count := count - l;
- if l > 0 then
- oe := FSRead(rn, l, @s[len + 1]);
- len := len + l;
- if oe = eofErr then
- oe := noErr;
- MyFSFill := oe;
- end;
- var
- oe, ooe: OSErr;
- ps: integer;
- search1, search2, search3: str15;
- l: longInt;
- begin
- p.expandtokens := true;
- s := p.fingeredname^;
- UprString(s, false);
- ps := Pos(spc, s);
- search2 := '';
- search3 := '';
- if ps = 0 then
- search1 := s
- else begin
- search1 := copy(s, 1, ps - 1);
- s := copy(s, ps + 1, 255);
- ps := Pos(spc, s);
- if ps = 0 then
- search2 := s
- else begin
- search2 := copy(s, 1, ps - 1);
- search3 := copy(s, ps + 1, 15);
- end;
- end;
- s := p.param^;
- if s = '' then
- s := ':Preferences:Lookup';
- oe := FSOpen(s, 0, rn);
- if oe = noErr then begin
- oe := GetEOF(rn, count);
- len := 0;
- oe := MyFSFill;
- while (oe = noErr) and (len > 0) do begin
- s[0] := chr(len);
- ps := Pos(cr, s);
- if ps = 0 then begin
- len := len + 1;
- s[len] := cr;
- ps := len;
- end;
- s[0] := chr(ps);
- t := s;
- UprString(s, false);
- if (Pos(search1, s) <> 0) and (Pos(search2, s) <> 0) and (Pos(search3, s) <> 0) then begin
- l := ps;
- if l > p.hlength - p.offset then
- l := p.hlength - p.offset;
- if l > 0 then begin
- BlockMove(@t[1], ptr(longInt(p.fingeroutput^) + p.offset), l);
- p.offset := p.offset + l;
- end;
- end;
- len := len - ps;
- if len > 0 then
- BlockMove(@s[ps + 1], @s[1], len);
- oe := MyFSFill;
- end;
- ooe := FSClose(rn);
- end;
- end;
-
- end.