home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frostbyte's 1980s DOS Shareware Collection
/
floppyshareware.zip
/
floppyshareware
/
USCX
/
TURBO-06.ZIP
/
JFYDIR.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-02-23
|
3KB
|
66 lines
{ This program demonstrates how to call BDOS routines in a TURBO PASCAL
program. The program will print the names of the files on the default
drive.
Copyright (C) April 1984, Jack Y. Fong
Commercial and publication rights are reserved.
Copies made for personal use are permitted and encouraged.
}
PROGRAM JYFDIR;
TYPE
{ This is the File Control Block, I made it a record but it does not
have to be a record.
}
FCB = RECORD
AFILE: STRING[44];
END;
{ This record defines the arguments for the BDOS and INTR functions
}
REGPACK = RECORD
AX,BX,CX,DX,BP,SI,DI,DS,ES,FLAGS: INTEGER;
END;
VAR
{ Allocate the variables.
}
FAT,DTA: FCB;
REGS: REGPACK;
BEGIN
{ Initialize the File Control Block , this area will be used by DOS to
hold the search information, once function 11 is executed do not
make any changes to this area if function 12 is to be used. }
FAT.AFILE := #255#0#0#0#0#0#0#0'???????????'#0#0#0#0 +
' ';
{ Initialize the Disk Transfer Area, this is where DOS will put the
FCB read in from the disk directory. It can be used by the program
for a FCB. Confusing isn't it? }
DTA.AFILE := #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0;
{ Pass the address of the DTA to the DOS . }
REGS.DS := SEG(DTA.AFILE); { Get segment value }
REGS.DX := OFS(DTA.AFILE)+1; { Get the offset, add one since the first
byte of a string stores the string length. }
{ Call MSDOS function 1AH to set the disk transfer address. }
REGS.AX := 6656; { Set AH to function 1AH, AL to 0 }
MSDOS(REGS);
{ Set the registers to the address of the search FCB. }
REGS.DS := SEG(FAT.AFILE); { Get segment value }
REGS.DX := OFS(FAT.AFILE)+1; { Get the offset, add one since the first
byte of a string stores the string length. }
{ Call MSDOS function 11H to search for the first file entry }
REGS.AX := 4352; { Set AH to function 11H, AL to 0 }
MSDOS(REGS);
WRITE(#10#13' ',COPY(DTA.AFILE,9,8),'.',COPY(DTA.AFILE,17,3));
{ Get the rest of the file names. }
REGS.AX := 4608; { Set AH to function 12H, AL to 0 }
WHILE REGS.AX = 4608 DO
BEGIN
MSDOS(REGS);
WRITE(#10#13' ',COPY(DTA.AFILE,9,8),'.',COPY(DTA.AFILE,17,3));
END;
END.AFILE,17,3));
END;
END.