DIR$ replacement by Plasma357
Interesting function using interrupts

Taken from a post in here: http://forum.qbasicnews.com/viewtopic.php?t=2890

' DIR$ replacement by Plasma357

DEFINT A-Z
'$INCLUDE: 'QB.BI'

DECLARE FUNCTION DIR2$ (fileSpec$, Attr)

CONST ANYDIR = &H10
CONST ANYFILE = &H27

CLS
n$ = DIR2$("C:\*.*", ANYDIR)
DO WHILE LEN(n$)
PRINT n$
n$ = DIR2$("", ANYDIR)
LOOP

FUNCTION DIR2$ (fileSpec$, Attr) STATIC

'Settings for Attr: (may be combined)
'
' &H40 Device
' &H20 Archive
' &H10 Directory
' &H8 Volume Label
' &H4 System File
' &H2 Hidden File
' &H1 Read-Only File

DIM DTA AS STRING * 44
fileSpecZ$ = fileSpec$ + CHR$(0)

DO

DIM Regs AS regTypeX

Regs.ax = &H1A00
Regs.ds = VARSEG(DTA)
Regs.dx = VARPTR(DTA)
InterruptX &H21, Regs, Regs

IF fileSpecZ$ <> CHR$(0) THEN
Regs.ax = &H4E00
Regs.cx = Attr
Regs.ds = VARSEG(fileSpecZ$)
Regs.dx = SADD(fileSpecZ$)
ELSE
Regs.ax = &H4F00
END IF

interruptX &H21, Regs, Regs

IF Regs.flags AND 1 THEN
DIR2$ = ""
EXIT FUNCTION
ELSE
realAttr = ASC(MID$(DTA, 22, 1))
IF realAttr AND Attr THEN
Null = INSTR(31, DTA, CHR$(0))
DIR2$ = MID$(DTA, 31, Null - 31)
EXIT FUNCTION
ELSE
fileSpecZ$ = CHR$(0)
END IF
END IF

LOOP

END FUNCTION


DirReplacement - page last edited 2003-06-01 08:55:43 by 81.203.196.78 (home) (edit)
Blast WIKI - by RoboticBoy - edited and tweaked for our evil purposes by Hexadecimal Disaster