home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
NEWS
/
554
/
JUILLET
/
EXTRACT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-10-07
|
2KB
|
74 lines
{─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
Msg : 53 of 62
From : Art Weller 1:381/85.0 29 Jun 93 06:30
To : Wayne Moses
Subj : Procedure Search
────────────────────────────────────────────────────────────────────────────────
I think you were the one looking for this. I'm surprised others haven't posted
better ones, so here it is.}
PROGRAM Extract;
{$V-}
uses dos, files, strings;
Var
Found : boolean;
i : byte;
Buf : Word;
LineNumber : integer;
Instr : String;
Str : String[15];
FileName : String[65];
InFile : Text;
BEGIN {main}
if ParamCount = 0 then
writeln('Syntax: EXTRACT filename<.PAS> <redirect>')
else
begin
LineNumber := 0;
Found := false;
FileName := ParamStr(1);
if pos('.',FileName) = 0 then FileName := FileName + '.PAS';
if OpenTextFile(InFile,FileName,'Input') then
begin
While not eof(InFile) do
begin
Readln(InFile,Instr);
Inc(LineNumber); {count the lines}
Str := copy(Instr,1,15);
ToLower(Str);
if (Pos('program',Str)<>0)
or (Pos('unit',Str)<>0)
or (Pos('function',Str)<>0)
or (Pos('procedure',Str)<>0) then
begin
Found := true;
Writeln(LineNumber:4,' ',Instr);
end
else
begin
if Found AND (Instr[1] = '{') then
Writeln(LineNumber:4,' ',Instr)
else Found := false;
end;
if (Pos('implementation', Str) = 1) then
begin
Close(InFile);
exit;
end;
end;
Close(InFile);
end;
end;
END.
I scribbled this somewhat hastily some time ago as I wanted to index my units.
It gets nested Procedures and Function from programs but only the interface
from units. You can modify to suit your self.
Uses a few things from my Files and Strings units but I think you can figure
them out from their names. If not, I'll be happy to post them.
This is free, in the public domain; therefore comes with a money-back guarantee