home *** CD-ROM | disk | FTP | other *** search
/ Frostbyte's 1980s DOS Shareware Collection / floppyshareware.zip / floppyshareware / USCX / TURBO-06.ZIP / JFYDIR.PAS < prev    next >
Pascal/Delphi Source File  |  1985-02-23  |  3KB  |  66 lines

  1. { This program demonstrates how to call BDOS routines in a TURBO PASCAL
  2.   program.  The program will print the names of the files on the default
  3.   drive.
  4.  
  5.   Copyright (C) April 1984, Jack Y. Fong
  6.   Commercial and publication rights are reserved.
  7.   Copies made for personal use are permitted and encouraged.
  8. }
  9.  
  10. PROGRAM JYFDIR;
  11.  
  12. TYPE
  13.   { This is the File Control Block, I made it a record but it does not
  14.     have to be a record.
  15.   }
  16.   FCB = RECORD
  17.           AFILE: STRING[44];
  18.           END;
  19.   { This record defines the arguments for the BDOS and INTR functions
  20.   }
  21.   REGPACK = RECORD
  22.           AX,BX,CX,DX,BP,SI,DI,DS,ES,FLAGS: INTEGER;
  23.           END;
  24.  
  25. VAR
  26.   { Allocate the variables.
  27.   }
  28.   FAT,DTA: FCB;
  29.   REGS: REGPACK;
  30.  
  31. BEGIN
  32. { Initialize the File Control Block , this area will be used by DOS to
  33.   hold the search information, once function 11 is executed do not
  34.   make any changes to this area if function 12 is to be used. }
  35.   FAT.AFILE := #255#0#0#0#0#0#0#0'???????????'#0#0#0#0 +
  36.                '                     ';
  37. { Initialize the Disk Transfer Area, this is where DOS will put the
  38.   FCB read in from the disk directory. It can be used by the program
  39.   for a FCB. Confusing isn't it? }
  40.   DTA.AFILE := #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
  41.                #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0;
  42. { Pass the address of the DTA to the DOS . }
  43.   REGS.DS := SEG(DTA.AFILE);  { Get segment value }
  44.   REGS.DX := OFS(DTA.AFILE)+1; { Get the offset, add one since the first
  45.                                  byte of a string stores the string length. }
  46. { Call MSDOS function 1AH to set the disk transfer address. }
  47.   REGS.AX := 6656;     { Set AH to function 1AH, AL to 0 }
  48.   MSDOS(REGS);
  49. { Set the registers to the address of the search FCB. }
  50.   REGS.DS := SEG(FAT.AFILE);  { Get segment value }
  51.   REGS.DX := OFS(FAT.AFILE)+1; { Get the offset, add one since the first
  52.                                  byte of a string stores the string length. }
  53. { Call MSDOS function 11H to search for the first file entry }
  54.   REGS.AX := 4352;     { Set AH to function 11H, AL to 0 }
  55.   MSDOS(REGS);
  56.   WRITE(#10#13' ',COPY(DTA.AFILE,9,8),'.',COPY(DTA.AFILE,17,3));
  57. { Get the rest of the file names. }
  58.   REGS.AX := 4608;     { Set AH to function 12H, AL to 0 }
  59.   WHILE REGS.AX = 4608 DO
  60.     BEGIN
  61.       MSDOS(REGS);
  62.       WRITE(#10#13' ',COPY(DTA.AFILE,9,8),'.',COPY(DTA.AFILE,17,3));
  63.     END;
  64. END.AFILE,17,3));
  65.     END;
  66. END.