home *** CD-ROM | disk | FTP | other *** search
- (****************************************************************************)
- (* GET DEFAULT DRIVE LETTER *)
- (****************************************************************************)
- function
- default_drive : char;
- begin
- regs.AX := $1900;
- msdos( regs );
- default_drive := chr(ord('A')+lo(regs.AX));
- end;
-
- (****************************************************************************)
- (* CHANGE DEFAULT DRIVE *)
- (****************************************************************************)
- procedure
- change_drive(dr : char);
- begin
- regs.AX := $0E00;
- regs.DX := ord(upcase(dr)) - ord('A');
- msdos( regs );
- end;
-
- (****************************************************************************)
- (* DISK SPACE AVAILABLE *)
- (****************************************************************************)
- function
- diskspace(dr : char) : integer;
- var
- r : real;
- begin
- regs.AX := $3600;
- regs.DX := ord(upcase(dr)) - pred(ord('A'));
- msdos( regs );
- r := ((regs.AX * regs.CX * 1.0) * regs.BX);
- diskspace := round( r / 1024.0);
- end;
-
- (****************************************************************************)
- (* TIME SERVICE ROUTINES *)
- (****************************************************************************)
- function
- time : string20;
- var
- h,m,s,w : string10;
- i : integer;
- begin
- regs.AX := $2C00;
- intr($21,regs);
- str(hi(regs.CX):2,h);
- str(lo(regs.CX):2,m);
- str(hi(regs.DX):2,s);
- w := h + ':' + m + ':' + s;
- for i:=2 to 8 do if w[i]=' ' then w[i]:='0';
- time:=w;
- end;
- function
- delta_time(t1,t2 : string20) : string20;
- var
- h,m,s : integer;
- th,tm,ts,tw : string10;
- begin
- h:=bval(copy(t2,1,3)) - bval(copy(t1,1,3));
- m:=bval(copy(t2,4,3)) - bval(copy(t1,4,3));
- s:=bval(copy(t2,7,3)) - bval(copy(t1,7,3));
- if s<0 then begin
- s:=s+60;
- m:=pred(m);
- end;
- if m<0 then begin
- m:=m+60;
- h:=pred(h);
- end;
- if h<0 then h:=h+24;
- str(h:2,th);
- str(m:2,tm);
- str(s:2,ts);
- tw:=th+':'+tm+':'+ts;
- for s:=2 to 8 do if tw[s]=' ' then tw[s]:='0';
- delta_time := tw;
- end;
-
- (****************************************************************************)
- (* DISPLAY CURRENT DRIVE\DIRECTORY *)
- (****************************************************************************)
- procedure
- displ_curr_dr;
- var
- curdir : string40;
- dn : integer;
- ch : char;
- begin
- ch := default_drive;
- dn := ord(ch) - pred(ord('A'));
- getdir(dn,curdir);
- writeln(' Current Drive\Directory: ',curdir);
- end;
-
- (****************************************************************************)
- (* FILE COPY ROUTINE *)
- (****************************************************************************)
- procedure
- copy_file;
- type
- buffer_pointer = ^buffer_type;
- buffer_type = array[ 1..128 ] of byte;
- var
- source, dest : file;
- sourcename : string40;
- destname : string40;
- recsread : integer;
- buff_pointer : buffer_pointer;
- begin
- mkwin(10,3,71,11,'File Copy');
- writeln;
- displ_curr_dr;
- writeln;
- repeat
- write(' Copy from: ');
- readln(sourcename);
- if length(sourcename)=0 then begin
- rmwin;
- exit;
- end;
- assign(source,sourcename);
- {$I-}
- reset(source);
- {$I+}
- ok := (ioresult=0);
- if not ok then
- writeln(' Cannot find file: ',sourcename);
- until ok;
- repeat
- write(' Copy to : ');
- readln(destname);
- if length(destname)=0 then begin
- close( source );
- rmwin;
- exit;
- end;
- assign(dest,destname);
- {$I-}
- rewrite(dest);
- {$I+}
- ok := (ioresult=0);
- if not ok then
- writeln(' Cannot create file: ',destname);
- until ok;
- new( buff_pointer );
- repeat
- blockread(source,buff_pointer^,1,recsread);
- blockwrite(dest,buff_pointer^,1);
- until recsread=0;
- close( dest );
- close( source );
- dispose( buff_pointer );
- rmwin;
- end;
-
- (****************************************************************************)
- (* DISK DIRECTORY HANDLERS *)
- (****************************************************************************)
- type
- Char40arr = array [ 1..40 ] of Char;
- (****************************************************************************)
- (* SetDTA resets the current DTA to the new address specified in the *)
- (* parameters 'SEGMENT' and 'OFFSET'. *)
- (****************************************************************************)
- procedure
- SetDTA( Segment, Offset : Integer; var Error : Integer );
- begin
- Regs.AX := $1A00;
- Regs.DS := Segment;
- Regs.DX := Offset;
- MSDos( Regs );
- Error := Regs.AX and $FF;
- end;
-
- (****************************************************************************)
- (* GetCurrentDTA is used to get the current Disk Transfer Area ( DTA ) *)
- (* address. A function code of $2F is stored in the high Byte of the AX *)
- (* register and a call to the predefined procedure MSDos is made. This *)
- (* can also be accomplished by using the "Intr" procedure with the same *)
- (* register record and a $21 specification for the interrupt. *)
- (****************************************************************************)
- procedure
- GetCurrentDTA( var Segment, Offset : Integer;
- var Error : Integer );
- begin
- Regs.AX := $2F00;
- MSDos( Regs );
- Segment := Regs.ES;
- Offset := Regs.BX;
- Error := Regs.AX and $FF;
- end;
-
- (****************************************************************************)
- (* GetFirst gets the first directory entry of a particular file Mask. The *)
- (* Mask is passed as a parameter 'Mask'. *)
- (****************************************************************************)
- procedure
- GetFirst( Mask : Char40arr; var NamR : String40;
- Segment, Offset : Integer; Option : Integer;
- var Error : Integer );
- var
- I : Integer;
- begin
- Error := 0;
- Regs.AX := $4E00;
- Regs.DS := Seg( Mask );
- Regs.DX := Ofs( Mask );
- Regs.CX := Option;
- MSDos( Regs );
- Error := Regs.AX and $FF;
- I := 1;
- repeat
- NamR[ I ] := Chr( mem[ Segment : Offset + 29 + I ] );
- I := succ(I);
- until ( not ( NamR[ pred(I) ] in [ ' '..'~' ] ));
- NamR[ 0 ] := Chr( pred(I) );
- end;
-
- (****************************************************************************)
- (* GetNextEntry uses the first bytes of the DTA for the file Mask, and *)
- (* returns the next file entry on disk corresponding to the file Mask. *)
- (****************************************************************************)
- procedure
- GetNextEntry( var NamR : String40; Segment, Offset : Integer;
- Option : Integer; var Error : Integer );
- var
- I : Integer;
- begin
- Error := 0;
- Regs.AX := $4F00;
- Regs.CX := Option;
- MSDos( Regs );
- Error := Regs.AX and $FF;
- I := 1;
- repeat
- NamR[ I ] := Chr( mem[ Segment : Offset + 29 + I ] );
- I := succ(I);
- until ( not ( NamR[ pred(I) ] in [ ' '..'~' ] ));
- NamR[ 0 ] := Chr( pred(I) );
- end;
-
- var
- mask : char40arr;
- dtaseg,dtaofs,error : integer;
- setdtaseg,setdtaofs : integer;
- dta : record
- dta_dos : array[1..26] of byte;
- lo_file_s1 : byte;
- lo_file_s2 : byte;
- hi_file_s1 : byte;
- hi_file_s2 : byte;
- dta_fname : array[1..13] of byte;
- end;
- namr : string40;
-
- procedure
- dir_list;
-
- {$I-}
-
- var
- i,j,option : Integer;
- Buffer : string40;
- horz_tab : byte;
-
- (****************************************************************************)
- (* LIST DIRECTORY OF DISK *)
- (****************************************************************************)
- begin
- mkwin(1,1,80,24,'Disk Directory');
- horz_tab := 4;
- for I := 1 to 40 do begin
- Mask[ I ] := Chr( 0 );
- NamR[ I ] := Chr( 0 );
- end;
- NamR[ 0 ] := Chr( 0 );
- GetCurrentDTA( DTAseg, DTAofs, Error );
- if ( Error <> 0 ) then begin
- WriteLn( 'Unable to get current DTA' );
- WriteLn( 'Program aborting.' );
- Halt;
- end;
- SetDTAseg := Seg( DTA );
- SetDTAofs := Ofs( DTA );
- SetDTA( SetDTAseg, SetDTAofs, Error );
- if ( Error <> 0 ) then begin
- WriteLn( 'Cannot reset DTA' );
- WriteLn( 'Program aborting.' );
- Halt;
- end;
- Error := 0;
- Buffer := '';
- Option:=16;
- displ_curr_dr;
- Write(' Dir Mask: ' );
- ReadLn( Buffer );
- WriteLn;
- if ( length( Buffer ) = 0 ) then
- Buffer := '*.*';
- for I := 1 to length( Buffer ) do
- Mask[ I ] := Buffer[ I ];
- GetFirst( Mask, NamR, SetDTAseg, SetDTAofs, Option, Error );
- if ( Error = 0 ) then begin
- gotoxy(horz_tab,wherey);
- Write( NamR );
- horz_tab := horz_tab + 15;
- end
- else
- WriteLn( ' File ''', Buffer, ''' not found.' );
- while ( Error = 0 ) do begin
- GetNextEntry( NamR, SetDTAseg, SetDTAofs, Option, Error );
- if ( Error = 0 ) then begin
- gotoxy(horz_tab,wherey);
- Write( NamR );
- horz_tab := horz_tab + 15;
- if horz_tab > 70 then begin
- horz_tab := 4;
- writeln;
- end;
- end;
- end;
- SetDTA( DTAseg, DTAofs, Error );
- if horz_tab > 4 then
- writeln;
- writeln;
- writeln(' Bytes Available: ',diskspace(default_drive),'k');
- write(' ');
- wait_for_key;
- rmwin;
- end;
-
- {$I+}