ihom@Nosc.ARPA (01/26/85)
>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