Megalextoria
Retro computing and gaming, sci-fi books, tv and movies and other geeky stuff.

Home » Archive » net.micro.cpm » Re(3): File sizes from Turbo & directory
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re(3): File sizes from Turbo & directory [message #113955] Tue, 17 September 2013 14:58
ihom is currently offline  ihom
Messages: 10
Registered: September 2013
Karma: 0
Junior Member
Message-ID: <7724@brl-tgr.ARPA>
Date: Sat, 26-Jan-85 11:03:06 EST
Article-I.D.: brl-tgr.7724
Posted: Sat Jan 26 11:03:06 1985
Date-Received: Wed, 30-Jan-85 06:29:51 EST
Sender: news@brl-tgr.ARPA
Organization: Ballistic Research Lab
Lines: 69

 > Do you have any idea how to get directory listings from Turbo? There's
 > probably an easy way out of that too that I don't know about...
 
Easy??  Well, not really.  To get a directory listing, you have to set
up the File Control Block (FCB) and call BDOS functions 11h (search for
first) and 12h (search for next).  In this example, bytes 0 to 11 will
be used in setting up the FCB.  Byte 0 is the drive number to access,
bytes 1 to 8 is the file name, and bytes 9 to 11 is the file type.  
Since we're searching the entire directory, fill the bytes for name and
type with 3Fh (questionmark) for *all* files.  When calling BDOS 11h,
if a file is found, the Direct Memory Address (DMA) is filled with the
record (128 bytes) containing the directory entry and returns a value
(0,1,2,3) indicating the starting position (each record contains 4
filenames of 32 bytes each).  Calling BDOS 12h continues the search in
the directory until no more files are found.  Something like this will
do the job:
 
program directory;
 
const                     { CP/M-80 BDOS calls }
  search_first = $0011;
  search_next = $0012;
  set_DMA  = $001A;
 
var
   first : boolean;
   i,directory_code : integer;
   DMA : array[1..128] of byte;
   FCB : array[0..11] of byte absolute $005C;
       { location of File Control Block }
 
procedure next;
   var
      ch : char;
      starting_position : integer;
      name : string[12];
   begin
      name := '';
      starting_position := directory_code * 32;     { get start of next file }
      for i:= starting_position + 1 to starting_position + 11 do
         begin
            ch := char(mem[addr(DMA) + i]);
            if i = starting_position + 9 then name := name + '.' + ch
               else name := name + ch
         end;
      writeln(name);
   end;
 
begin
   bdos(set_DMA,addr(DMA));     { allocate a record of memory for the DMA }
   FCB[0] := 0;     { drive # to access:  0 = A, 1 = B, ...}
   for i := 1 to 11 do      { fill FCB with '?'s to match all files }
      FCB[i] := $3F;
   first := true;
   repeat
      { get directory_code of file given by the FCB }
      if first then
         directory_code := bdos(search_first,addr(FCB))
      else
         directory_code := bdos(search_next);     { continue search }
      first := false;
      if directory_code <> $FF then next;     { file present? }
   until directory_code = $FF;     { no more files }
end.


--Irwin Hom          {ihnp4, sdcsvax!bang}!crash!ihom
				 bang!crash!ihom@nosc
				 bang!crash!ihom@ucsd
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Turbo Pascal output
Next Topic: 15 MBYTE HARD-DISC
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Apr 19 02:04:22 EDT 2024

Total time taken to generate the page: 0.11714 seconds