home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / TURBO.ZIP / GETDIR.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1984-06-28  |  2.1 KB  |  104 lines

  1. PROGRAM DIR;
  2. {
  3.            JUNE 28, 1984
  4.  
  5.            Author:       Todd Little
  6.                          1318 Bullock
  7.                          Houston, TX  77055
  8.                          713-984-2055 h
  9.                              578-3210 w
  10.  
  11. }
  12.  
  13. var
  14.    es,bx :integer;
  15.    al :byte;
  16.    file_search : string[20];
  17.  
  18. procedure getdta;
  19.  
  20. {
  21.    Get the current DTA (data transfer address)
  22.    Use the DOS call 2f to put the DTA into ES:BX
  23.    Then put these into the variables of the same name
  24.  
  25. }
  26. begin
  27.   inline
  28.     ( $b4/$2f/          {mov ah,2f}
  29.       $cd/$21/          {int,21}
  30.       $89/$1e/bx/       {mov (bx),bx  }
  31.       $8c/$c3/          {mov bx,es }
  32.       $89/$1e/es        {mov (es),bx  }
  33.         )
  34.    end;
  35.  
  36.  
  37.  
  38. procedure getdir(var file_search);
  39.  
  40. {
  41.     Get the directory by using the find first operation, dos call 4e
  42.     get subsequent entries using dos call 4f
  43.  
  44.     file_search  should contain the matching parameters, i.e. *.*
  45. }
  46. var
  47.    i,j : integer;
  48.    file_name : string[20];
  49.  
  50.  
  51. begin
  52.  
  53.  
  54.    begin;
  55.       inline  (
  56.          $8b/$56/$04/    {mov dx,[bp+04]    point to file_search}
  57.          $81/$c2/$01/$00/{add dx,0001       move past the string length}
  58.          $b9/$00/$00/    {mov cx,0010       search for files (inc dir)}
  59.          $b4/$4e/        {mov ah,4e         dos call 4e}
  60.          $cd/$21/        {int 21h           }
  61.          $a2/al          {mov (al),al       save the error code}
  62.            )
  63.       end;
  64.  
  65.    j := 0;
  66.    writeln;
  67.  
  68.    while (al <> 02) and (al <> 18) do
  69.    begin
  70.  
  71.       if j mod 5 = 0 then
  72.          writeln;
  73.  
  74.       i := 30;
  75.       file_name := '';
  76.  
  77.       while mem[es:bx+i] <> 0 do
  78.       begin
  79.         file_name := concat(file_name,chr(mem[es:bx+i]) );
  80.         i := i +1;
  81.       end;
  82.  
  83.       write(file_name:15);
  84.       j := j +1;
  85.  
  86.       begin
  87.       inline  (
  88.          $b4/$4f/        {mov ah,4f         find next}
  89.          $cd/$21/        {int 21h           with dos call 4f}
  90.          $a2/al          {mov (al),al       save return code}
  91.            )
  92.       end;
  93.  
  94.   end;
  95.  
  96. end;
  97.  
  98. begin
  99.  
  100.    getdta;
  101.    file_search := concat( '*.*',chr(0) );
  102.    getdir(file_search);
  103.    end.
  104.