home *** CD-ROM | disk | FTP | other *** search
- {S-,R-,V-,D-,T-}
- {\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\}
- { TechnoJocks Turbo Toolkit v4.05 Released: Jul 18, 1988 }
- { }
- { Module: DirTTT -- a directory displying unit }
- { }
- { Copyright R. D. Ainsbury (c) 1986-88 }
- {\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\}
-
- Unit DirTTT;
-
- Interface
-
- Uses CRT, FastTTT, DOS, KeyTTT, WinTTT;
-
- Function Display_Directory(var PathName:string; FileMask:string): string;
- Procedure Default_Settings;
-
- Type
- DirDisplay = record
- TopX : byte;
- TopY : Byte;
- Cols : byte;
- Rows : byte;
- DateTime: boolean;
- CDir : boolean;
- Attrib : byte;
- BoxType : byte;
- BoxCol : byte;
- BacCol : byte;
- NorCol : byte;
- DirCol : byte;
- HiFCol : byte;
- HiBCol : byte;
- AllowEsc : boolean;
- end;
-
- Var
- D : DirDisplay;
-
- Implementation
-
- Procedure Default_Settings;
- begin
- With D do
- begin
- TopX := 15;
- TopY := 5;
- Cols := 4;
- Rows := 15;
- DateTime:= true;
- CDir := true;
- AllowEsc := true;
- Attrib := AnyFile;
- BoxType := 1; {single lined box}
- If BaseOfScreen = $b000 then
- begin
- BoxCol := white;
- BacCol := black;
- NorCol := white;
- DirCol := lightgray;
- HiFcol := black;
- HiBcol := lightgray;
- end
- else
- begin
- BoxCol := red;
- BacCol := lightgray;
- NorCol := black;
- DirCol := yellow;
- HiFcol := white;
- HiBcol := blue;
- end;
- end; {with}
- end;
-
- Function Display_Directory(var PathName:string; FileMask:string): string;
-
- Const
- Mcols = 6; {lower these settings to reduce the amount of}
- Mrows = 23; {memory used - if necessary}
- Lchar = #16;
- Rchar = #17;
- Null = #0;
- HomeKey = #199; EndKey = #207; Esc = #027; Enter = #13;
- Cursup = #200; CursDown = #208; CursLeft = #203; CursRight = #205;
- PgDn = #209; PgUp = #201;
-
- Type
- Filerecord = record
- Name : string[12];
- Size : LongInt;
- Time : LongInt;
- Attr : byte;
- end;
- DirBox = array[1..Mcols,1..Mrows] of ^Filerecord;
- DirectoryData = record
- CurrEntry : byte; { the number of the highlighted file }
- TotFiles : byte; { the total number of files in cur. box }
- CurrPage : integer; { current directory page number}
- FileData : DirBox; { name and attrib info }
- MoreFiles : boolean; { true if not end of directory }
- end;
- Var
- Dbox : DirectoryData; {array of files and attributes}
- X2 : byte; {right hand box coord}
- I,J : integer; {misc}
-
- {\\\\\\\\\\\\\\\\\\\\\\ Miscellaneous procedures \\\\\\\\\\\\\\\\\\\\\}
-
- FUNCTION Copies (ch:char; n:integer) : String;
- begin
- InLine ( $16 /$07 /$8B /$4E /$04 /$88 /$4E /$08 /$8B
- /$46 /$06 /$8D /$7E /$09 /$FC /$F3 /$AA );
- end; { Copies }
-
-
- Function Left(S : string;Size : byte; Pad : char):string;
- var temp : string;
- begin
- Fillchar(Temp[1],Size,Pad);
- Temp[0] := chr(Size);
- If Length(S) <= Size then
- Move(S[1],Temp[1],length(S))
- else
- Move(S[1],Temp[1],size);
- Left := Temp;
- end;
-
- Function Center(S : string;Size : byte; Pad : char):string;
- var
- temp : string;
- L : byte;
- begin
- Fillchar(Temp[1],Size,Pad);
- Temp[0] := chr(Size);
- L := length(S);
- If L <= Size then
- Move(S[1],Temp[((Size - L) div 2) + 1],L)
- else
- Move(S[((L - Size) div 2) + 1],Temp[1],Size);
- Center := temp;
- end; {center}
-
- Function Int_to_Str(I : Longint):string;
- var S : string[11];
- begin
- Str(I,S);
- Int_to_Str := S;
- end;
-
- Function CalcCol(Entry : byte) : byte;
- { returns the display column of the file}
- begin
- CalcCol := Succ(Pred(Entry) MOD D.cols);
- end;
-
- Function CalcRow(Entry : byte) : byte;
- { returns the display row of the file}
- begin
- CalcRow := Pred(Entry + D.cols) DIV D.cols;
- end;
-
- Function Subdirectory(Attrib:byte): boolean;
- begin
- Subdirectory := ((Attrib and 16) = 16);
- end;
-
- Function ValidPathName:Boolean;
- begin
- If PathName[Length(PathName)] <> '\' then
- PathName := PathName + '\';
- {$I-}
- If (length(PathName) = 3) and (PathName[2] = ':') then
- Chdir(PathName)
- else
- ChDir(copy(Pathname,1,length(Pathname) - 1));
- {$I+}
- ValidPathName := (IoResult = 0);
- end; {ValidPathName}
-
- Function FileDetails(F:FileRecord):string;
- var
- DT : DateTime;
- Str: string;
- begin
- UnPackTime(F.Time,DT);
- Str := Int_to_Str(F.Size)+' '
- +Int_to_Str(DT.Month)+'-'+Int_to_Str(DT.Day)+'-'
- +copy(Int_to_Str(DT.Year),3,2)
- +' '+Int_To_Str(DT.Hour)+':'+Int_to_Str(DT.Min);
- FileDetails := Str;
- end;
-
- Function ExtractPrevDir(Path : string): string;
- begin
- Repeat
- Delete(Path,length(Path),1);
- Until ( copy(Path,length(Path),1) = '\') or (length(Path) = 0);
- Delete(Path,length(Path),1);
- If length(Path) > 2 then
- ExtractPrevDir := Path0)string;string;sd d d;
- ;
- ;wswsw((L((L(FUFUFeft(chrchar(mp[mp[m '
- r r r TLef┬TITITY imto_Se -cur /$4 /$4 B B B;
- v;
- v;AnAnAed Xtra : byte;
- begin
- If D.DateTime then
-
-
- ra := 1
- else
- a := 0;
- If D.
- IfTime and (D.cols < 4) then n ns := 4; s s .colsolso 1) or (D(D( 1) > 6) then D.cols := 6;
- := 0:= 0:Rows or1)s := 6 := 6 FUFxt (D> 23) then D. D. := 23 - - a;
- If 1)sTopX