home *** CD-ROM | disk | FTP | other *** search
- unit MakeCls;
-
- { Program copyright (c) 1995 by Charles Calvert }
- { Project Name: EXPLORER }
-
- interface
-
- uses
- Classes,
- SysUtils,
- Forms,
- StrUtils,
- Status,
- Dialogs;
-
- procedure MakeList(SubDirList: TStringList; OutFile: String);
-
- implementation
-
- uses
- WinTypes,
- WinProcs,
- Messages;
-
- function IsUnique(ClassName: String; SList: TStringList): Boolean;
- var
- Dup: Boolean;
- i: Integer;
- begin
- Dup := False;
- for i := 0 to SList.Count - 1 do begin
- if ClassName = GetFirstWord(SList.Strings[i]) then begin
- Dup := True;
- break;
- end;
- end;
- IsUnique := Dup;
- end;
-
- function Parse(var OutList: TextFile; S, FName: String;
- SList: TStringList) : String;
- var
- Temp, Answer, ClassName, Parent: String;
- Len, OffSet: Integer;
- T: Boolean;
- Position: Integer;
- AddMe : Integer;
- begin
- Temp := '';
- S := StripSpaces(S);
- OffSet := Pos('=class(', S);
- Addme := Length('=class(');
-
- if OffSet = 0 then
- begin
- OffSet := Pos('=object(', S);
- AddMe := Length('=object(');
- end;
-
- if OffSet > 0 then begin
- Temp := S;
- ClassName := Copy(Temp, 1, (Pos('=', S) - 1));
- Parent := Copy(Temp, (Offset + AddMe), Length(S));
- Position := Pos(')', Parent);
- if Position <> 0 then Parent[0] := Chr(Position - 1);
- Answer := LeftSet(ClassName, 25, T) + LeftSet(Parent, 25, T) + FName;
- if not IsUnique(ClassName, SList) then
- SList.Add(Answer);
- end;
- Parse := Temp;
- end;
-
-
- procedure ProcessList(var OutList: TextFile; SubDir, FName: String;
- SList: TStringList);
- var
- F: TextFile;
- Temp, S: String;
- begin
- AssignFile(F, AddBackSlash(SubDir) + FName);
- Reset(F);
- while not EOF(F) do begin
- ReadLn(F, S);
- Temp := Parse(OutList, S, FName, SList);
- end;
- CloseFile(F);
- end;
-
- procedure FindDir(var OutList: TextFile; SubDir: String;
- var TotalFiles: Integer; SList: TStringList);
- var
- SR: TSearchRec;
- StTotalFiles : String;
- FindError: Integer;
- begin
- FindError := FindFirst(AddBackSlash(SubDir) + '*.pas', faArchive, SR);
- while FindError = 0 do begin
- Application.ProcessMessages;
- Inc(TotalFiles);
- UpStatus.Label3.Caption := SR.Name;
- Str(TotalFiles, StTotalFiles);
- UpStatus.Label5.Caption := StTotalFiles;
- ProcessList(OutList, SubDir, SR.Name, SList);
- FindError := FindNext(SR);
- end;
- end;
-
- var
- OutList: TextFile;
- TotalFiles: Integer;
- SList: TStringList;
-
- procedure MakeList(SubDirList: TStringList; OutFile: String);
- {
- This procedure creates the list that is used by the Object Explorer.
- It takes a TStringList that contains a list of subdirs to parse and
- a string that contains the path and name of the Output file.
- }
- var
- i : integer;
- p : integer;
- begin
- TotalFiles := 0;
- SList := TStringList.Create;
- AssignFile(OutList, OutFile);
- Rewrite(OutList);
- UpStatus.Show;
- for i := 1 to SubDirList.Count do
- FindDir(OutList, SubDirList.Strings[i-1], TotalFiles, SList);
- UpStatus.Close;
- CloseFile(OutList);
- SList.SaveToFile(OutFile);
- SList.Free;
- end;
-
- end.
-