home *** CD-ROM | disk | FTP | other *** search
- {This program is written by Micheal J. Chatfield CS #71250,2766
- this source code is presented as is and I assume no responsibility
- for any errors in the source, nor any responsibility for any damages.
- I am releasing this into the public domain}
- {$M 16384, 22000, 22000 }
- {$R-,S-,I+,D-,T-,F-,V-,B-,N-,L+ }
- uses Crt,Qwik,WndwVars,dos,Wndw;
-
- {WindVars,Wndw,and Qwik units are written and copywrited (shareware)
- by James H. Lemay (CS76011,217), thanks to James for some
- very powerfull screen handling utilities}
-
- var
- cmd : char;
- i,j,k,m,OldCursor : word;
- real1,real2,real3 : real; {variables for calculating percentage}
- totalspacefree,
- totaldvsize,
- userdatasize : longint;
- s : string[6];
- s1 : string[5];
- s2 : string[1];
- s3 : string[6];
- s4 : string[1];
- usrsz : string[10];
- procedure CheckCursor;
- var
- CursorMode: integer absolute $0040:$0060;
- begin
- if (ActiveDispDev=MdaMono) and (CursorMode=$0607) then
- CursorChange($0C0D,OldCursor);
- end;
- procedure ShowDriveSpace; {Displays Bytes on each partition and Total Bytes}
- var
- Drive,
- ValidDrive : byte;
- freestg : string[10];
- s : string[9];
- FreeBytes,
- runtotal,
- hold,
- result : longint;
- begin
- hold := 0; {Init hold variable to zero for adding total bytes}
- Drive := 2; {Skip Floppy A & B by setting to 2, include set to 0}
- ValidDrive:= 0; {Init ValidDrive variable to zero}
- FreeBytes := 0; {Init FreeBytes variable to zero}
- hold := 0; {Init hold variable to zero}
- freestg :='';
- s :='';
- while (Drive < 26) and (ValidDrive < 26) do
- begin
- gotoxy((7 + ValidDrive mod 5 * 13),(1 + ValidDrive div 5));
- inc(Drive); {Set up Display within the active window}
- FreeBytes:= diskfree(Drive); {Move result of diskfree to FreeBytes}
- if FreeBytes > 0 then {Add up all Partitions in Bytes}
- begin
- hold:=hold + FreeBytes; {Keep track of running total}
- totalspacefree:=hold;
- end;
- if (FreeBytes >= 0) then {if any Bytes on any Partition Display It}
- begin
- write(chr((Drive - 1) + ord('A')),':');
- write(FreeBytes:9,s);
- inc(ValidDrive); {Go to the next Drive}
- end;
- if Drive = 26 then
- begin;
- MakeWindow (9,2,3,39,green,cyan+redBG,Borders(11),Window5);
- TitleWindow(Top,Center,' Total Available Storage ');
- accesswindow(window5);
- str(hold,freestg);
- QwriteC(10,3,39,2,freestg);
- end;
- end;
- end; { procedure ShowDriveSpace and Total Space}
- procedure ShowDriveSize; {Displays Max Size on each partition and Total Bytes}
- var
- Drive,
- ValidDrive : byte;
- s : string[9];
- maxstg : string[10];
- TotalBytes,
- hold1 : longint;
- begin
- Drive := 2; {Skip Floppy A & B by setting to 2, include set to 0}
- ValidDrive := 0; {Init ValidDrive variable to zero}
- TotalBytes := 0; {Init TotalBytes variable to zero}
- hold1 := 0; {Init hold1 variable, keeps track of the running total}
- s :='';
- maxstg :='';
- while (Drive < 26) and (ValidDrive < 26) do
- begin
- gotoxy((7 + ValidDrive mod 5 * 13),(1 + ValidDrive div 5));
- inc(Drive); {Set up Display within the active window}
- TotalBytes:= Disksize(Drive); {Move result of diskfree to FreeBytes}
- if Totalbytes >= 0 then {Add up all Partitions in Bytes}
- begin
- hold1:=hold1 + Totalbytes; {Keep track of running total}
- end;
- totaldvsize:=hold1;
- if (TotalBytes > 0) then {if any Bytes on any Partition Display It}
- begin
- write(chr((Drive - 1)+ ord('A')),':');
- write(TotalBytes:9,s);
- inc(ValidDrive); {Go to the next Drive}
- end;
- if Drive = 26 then
- begin
- MakeWindow (9,41,3,39,green,cyan+redBG,Borders(11),Window4);
- TitleWindow(Top,Center,' Total Storage Capacity ');
- accesswindow(window4);
- str(hold1,maxstg);
- QwriteC(10,41,78,2,maxstg);
- end;
- end;
- end;
- begin {Main Program} { The equivalent to the Unix DF command }
- { Initialize program variables }
- totalspacefree :=0;
- totaldvsize :=0;
- userdatasize :=0;
- real1 :=0;
- real2 :=0;
- real3 :=0;
- s1 :='';
- s2 :='';
- s3 :='';
- s4 :='';
- qinit;
- clrscr;
- initwindow (0,false); { set up windows }
- setwindowmodes ($10);
- CheckCursor;
- CursorOff;
- MakeWindow (1,2,8,78,white+green+yellow+blackBG,lightgray+redBG,Borders(7),Window2);
- TitleWindow(Top,Center,' Unused Storage on Each Partition ');
- accesswindow(window2);
- showdrivespace; {Shows Free Space on each Partition}
- MakeWindow (12,2,8,78,white+green+yellow+blackBG,lightgray+redBG,Borders(7),Window3);
- TitleWindow(Top,Center,' Size of Each Partition ');
- accesswindow(window3);
- showdrivesize; {Shows Max Space on each Partition}
- MakeWindow (23,21,2,40,black,cyan+red,Borders(7),Window6);
- TitleWindow(Top,Center,' Q to Quit ');
- accesswindow(window6);
- MakeWindow (20,2,3,39,green,cyan+redBG,Borders(11),Window7);
- TitleWindow(Top,Center,' User Data Stored in Bytes ');
- accesswindow(window7);
- userdatasize:= (totaldvsize mod totalspacefree); {calculate user date stored}
- str(userdatasize,usrsz); {convert to a string}
- QwriteC(21,3,39,2,usrsz);
- MakeWindow (20,41,3,39,green,cyan+redBG,Borders(11),Window8);
- TitleWindow(Top,Center,' Percent Free All Partitions ');
- accesswindow(window8);
- real1:=totaldvsize;
- real2:=totalspacefree;
- real3:=(real2 / real1);
- str(real3:12:5,s);
- s1:=copy(s,3,4); {Get the percentage value from the Longint into string}
- s4:='.';
- s2:='%';
- s3:=concat(s1,s2);
- insert(s4,s3,3);
- QwriteC(21,41,78,2,s3);
- repeat
- cmd :=readkey;
- until (cmd = 'q') or (cmd = 'Q');
- begin
- removewindow;
- removewindow;
- removewindow;
- removewindow;
- removewindow;
- removewindow;
- removewindow;
- cursoron; {Turn Cursor back on}
- end;
- end. {End Main Program Body}
-