home *** CD-ROM | disk | FTP | other *** search
- Procedure ListDirectory;
-
- { This procedure lists out all the valid input data files with the declared
- input data file extension constant in the directory window. }
-
- Type { ListDirectory }
- CharArray=Array [1..12] Of Char; { array type of character used in looking for input data files }
- WorkString=String[20]; { string type used for file names }
- RecordOfRegisters= { a record type to store the integer values of the 8088 internal registers }
- Record
- AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags : Integer; { Registers }
- End; { RecordOfRegisters }
-
- Var
- Registers:RecordOfRegisters; { record variable used to store the integer values of the 8088 internal registers }
- DTA:Array [ 1..43 ] Of Byte; { Data Transfer Area }
- Mask:CharArray; { an array used to store the input file name mask }
- FileName:WorkString; { a variable used to store a filename found in the directory }
- Error:Integer; { a variable used to store the returned error code }
- I:Integer; { an index counter used in returning file names }
- J:Integer; { an index counter used in placing spaces between the acquired file names }
-
- Begin
- FillChar(DTA,SizeOf(DTA),0); { initialize the DTA buffer }
- FillChar(Mask,SizeOf(Mask),0); { initialize the mask }
- FillChar(FileName,SizeOf(FileName),0); { initialize the file name }
- Registers.AX:=$1A00; { function used to set the DTA }
- Registers.DS:=Seg(DTA); { store the parameter segment in the data egment register DS }
- Registers.DX:=Ofs(DTA); { stare the parameter offset in the data register DX }
- MSDos(Registers); { set DTA location }
- Error:=0; { initialize error flag }
- Mask:='????????.???'; { use for search of input data files }
- Mask[9]:=EXTENSION[1]; { used for looking for input files with a particular file name extension }
- Mask[10]:=EXTENSION[2];
- Mask[11]:=EXTENSION[3];
- Mask[12]:=EXTENSION[4];
- Registers.AX:=$4E00; { get first directory entry }
- Registers.DS:=Seg(Mask); { point to the file Mask }
- Registers.DX:=Ofs(Mask);
- Registers.CX:=22; { store the option }
- MSDos(Registers); { execute MSDos call }
- Error:=Registers.AX and $FF; { get Error return }
- I:=1; { initialize 'I' to the first element }
- If (Error=0) Then
- Repeat
- FileName[I]:=Chr(Mem[Seg(DTA):Ofs(DTA)+29+I]);
- I:=I+1;
- Until Not (FileName[I-1] in [' '..'~']) or (I>20);
- FileName[0] := Chr(I-1); { set string length because assigning by element does not set length }
- If (Error=0) Then
- Begin { remove data file name extension }
- Delete(FileName,Length(FileName)-4,4);
- Write(FileName);
- For J:=Length(FileName)+1 To 10 Do { place spaces between file names so that they line up vertically }
- Write(' ');
- End; { If Error }
- While (Error=0) Do
- Begin
- Error:=0; { initialize error flag }
- Registers.AX:=$4F00; { function used to get the next directory entry }
- Registers.CX:=22; { set the file option }
- MSDos(Registers); { call MSDos }
- Error:=Registers.AX and $FF; { get the Error return }
- I:=1;
- Repeat
- FileName[I]:=Chr(Mem[Seg(DTA):Ofs(DTA)+29+I]);
- I:=I+1;
- Until Not (FileName[I-1] in [' '..'~'] ) or (I > 20);
- FileName[0]:=Chr(I-1);
- If (Error=0) Then
- Begin { remove data file name extension }
- Delete(FileName,Length(FileName)-4,4);
- Write(FileName);
- For J:=Length(FileName)+1 To 10 Do { place spaces between file names so that they line up vertically }
- Write(' ');
- End; { If Error }
- End; { While Error }
- End; { ListDirectory }
-