QB doesn't have a built-in way, other than using FILES. You can see this QBKB doc on advanced ways for using FILES:
http://kb.qbasicnews.com/Q32724.TXT
Like Opresion mentioned, there are a few DIR$ like routines in the ABC archives -- look in the DOS section for them.
I'll post one I've found in there, made by Dave Cleary:
- Dav
http://kb.qbasicnews.com/Q32724.TXT
Like Opresion mentioned, there are a few DIR$ like routines in the ABC archives -- look in the DOS section for them.
I'll post one I've found in there, made by Dave Cleary:
Quote:'DIR.BAS by Dave Cleary
'
'One of the most useful additions to BASIC 7 PDS is the DIR$ function.
'This function allows you to read a directory of filenames. It also
'allows you to check the existence of a file by doing the following:
'
'Â IF LEN(DIR$("COMMAND.COM")) THEN
'Â Â Â PRINT "File Found"
'Â ELSE
'Â Â Â PRINT "File not found"
'Â END IF
'
'Now QuickBASIC 4.X users can have this useful function for their
'programs.
'
'Calling DIR$ with a FileSpec$ returns the the name of the FIRST
'matching file name. Subsequent calls with a null FileSpec$ return the
'NEXT matching file name. If a null string is returned, then no more
'matching files were found. FileSpec$ can contain both a drive and a
'path plus DOS wildcards. Special care should be taken when using
'this on floppy drives because there is no check to see if the drive
'is ready.
DEFINT A-Z
DECLARE FUNCTION DIR$ (FileSpec$)
'$INCLUDE: 'QB.BI'
'-----Â Some constants that DIR$ uses
CONST DOS = &H21
CONST SetDTA = &H1A00, FindFirst = &H4E00, FindNext = &H4F00
'--------------------------------------------------------------------
'This shows how to call DIR$ to find all matching files
CLS
FileSpec$ = "C:\QB\*.*"
Found$ = DIR$(FileSpec$)
DO WHILE LEN(Found$)
  PRINT Found$
  Found$ = DIR$("")
LOOP
'--------------------------------------------------------------------
FUNCTION DIR$ (FileSpec$) STATIC
  DIM DTA AS STRING * 44, Regs AS RegTypeX
  Null$ = CHR$(0)
'-----Â Set up our own DTA so we don't destroy COMMAND$
  Regs.AX = SetDTA          'Set DTA function
  Regs.DX = VARPTR(DTA)        'DSX points to our DTA
  Regs.DS = -1            'Use current value for DS
  InterruptX DOS, Regs, Regs     'Do the interrupt
'-----Â Check to see if this is First or Next
  IF LEN(FileSpec$) THEN       'FileSpec$ isn't null, so
  'FindFirst
FileSpecZ$ = FileSpec$ + Null$Â Â 'Make FileSpec$ into an ASCIIZ
  'string
Regs.AX = FindFirst       'Perform a FindFirst
Regs.CX = 0Â Â Â Â Â Â Â Â Â Â Â 'Only look for normal files
Regs.DX = SADD(FileSpecZ$)Â Â Â Â 'DSX points to ASCIIZ file
Regs.DS = -1Â Â Â Â Â Â Â Â Â Â Â 'Use current DS
  ELSE                'We have a null FileSpec$,
Regs.AX = FindNext        'so FindNext
  END IF
  InterruptX DOS, Regs, Regs     'Do the interrupt
'-----Â Return file name or null
  IF Regs.Flags AND 1 THEN      'No files found
DIR$ = ""Â Â Â Â Â Â Â Â Â Â Â Â 'Return null string
  ELSE
Null = INSTR(31, DTA, Null$)Â Â Â 'Get the filename found
DIR$ = MID$(DTA, 31, Null - 30)Â 'It's an ASCIIZ string starting
  END IF               'at offset 30 of the DTA
END FUNCTION
- Dav
Visit Dav's Qbasic Site