×
Menu
Index

FINDFIRST, FINDNEXT Subroutines

 
Usage:
f = FINDFIRST([s])
f = FINDNEXT(f)
 
Description:
Use these subroutines to iterate through system files.
The optional argument to FINDFIRST indicates the filespec used to filter the files returned. If the argument is omitted, "*.*" is used.
 
The value returned by FINDFIRST can then be passed to FINDNEXT repeatedly to iterate through all the files matching the filespec.
 
The value returned is the name of the file. Both subroutines return an empty filename ("") when there are no more matching files. The returned value has several members that contain additional information about the current file. These members are NAME, DATE, TIME, SIZE, ATTRIB, CDATE, CTIME, ADATE, ATIME, MODE and SFN (if different than NAME). TBSVER 5 adds sortable date and time values of DATETIME, CDATETIME, ADATETIME.
 
In order to close the internal find handle you should empty the variable holding the returned value when you abort the find operation before an empty filename("") is obtained. (e.g. f=" ")
 
Example:
sub main()
   f = findfirst("*.*")
   while len(f) > 0
      c = c + 1
      print(" ", f.date)
      print(" ", f.time)
      print(" ", f.size)
      print(" ", f.attrib)
      printl(f.name)
      f = findnext(f)
   wend
   printl(c, " file(s)")
end sub