home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / TURBO.ZIP / GETDIR.INC < prev    next >
Encoding:
Text File  |  1984-09-26  |  1.7 KB  |  64 lines

  1. var es,bx :INTEGER; al :BYTE; file_search : STRING[20];
  2.  
  3. PROCEDURE getdta;
  4. {Get the current DTA (data transfer address)}
  5. BEGIN
  6.   INLINE
  7.     ( $b4/$2f/          {mov ah,2f}
  8.       $cd/$21/          {int,21}
  9.       $89/$1e/bx/       {mov (bx),bx  }
  10.       $8c/$c3/          {mov bx,es }
  11.       $89/$1e/es        {mov (es),bx  }
  12.         )
  13.    END;
  14.  
  15. PROCEDURE getdir(VAR file_search);
  16. {Get the directory by using the find first operation, dos call 4e
  17.     get subsequent entries using dos call 4f
  18.     file_search  should contain the matching parameters, i.e. *.*}
  19. VAR
  20.    i,j : INTEGER;
  21.    file_name : STRING[20];
  22. BEGIN
  23.    BEGIN;
  24.       INLINE  (
  25.          $8b/$56/$04/    {mov dx,[bp+04]    point to file_search}
  26.          $81/$c2/$01/$00/{add dx,0001       move past the string length}
  27.          $b9/$00/$00/    {mov cx,0010       search for files (inc dir)}
  28.          $b4/$4e/        {mov ah,4e         dos call 4e}
  29.          $cd/$21/        {int 21h           }
  30.          $a2/al          {mov (al),al       save the error code}
  31.            )
  32.       END;
  33.    j := 0;
  34.    WRITELN;
  35.    WHILE (al <> 02) AND (al <> 18) DO
  36.    BEGIN
  37.       IF j MOD 5 = 0 THEN
  38.          WRITELN;
  39.       i := 30;
  40.       file_name := '';
  41.       WHILE MEM[es:bx+i] <> 0 DO
  42.       BEGIN
  43.         file_name := CONCAT(file_name,CHR(MEM[es:bx+i]) );
  44.         i := i +1;
  45.       END;
  46.       WRITE(file_name:15);
  47.       j := j +1;
  48.       BEGIN
  49.       INLINE  (
  50.          $b4/$4f/        {mov ah,4f         find next}
  51.          $cd/$21/        {int 21h           with dos call 4f}
  52.          $a2/al          {mov (al),al       save return code}
  53.            )
  54.       END;
  55.   END;
  56. END;
  57.  
  58. procedure DoDir;
  59. BEGIN
  60.    getdta;
  61.    file_search := CONCAT( '*.*',CHR(0) );
  62.    getdir(file_search);
  63. END;
  64.