Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - findfirst() locate the first file matching a search pattern http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 findfirst()         Locate the first file matching a search pattern
------------------------------------------------------------------------------
 Declaration
   file.hdr

 Syntax
   func logical findfirst extern
   param const char cPattern, ;
         value uint uAttribute

 Arguments
   cPattern is the path/file specification.
   uAttribute is the attribute specification for the files to find.

 Return
   A logical indicating if a matching file has been found.

 Description
   The findfirst() function locates the first file matching cPattern. It
   returns .t. if the file is found, else it returns .f.

   cPattern is the file or directory path. findfirst() supports the DOS
   wildcard characters * and ?.

   To find the next file within a sequence, use the findnext() function.

   Use the function findfstr() to obtain the filename found by findfirst().
   The functions findfdate(), findftime() and findfsize() return the file's
   date, time and size, respectively.

   The parameter uAttribute specifies what types of files are to be located.
   The include file file.hdr contains common defines for attributes. See
   also the File attributes table. To search for normal files, use the
   FIND_ARCHIVE macro.

 Example
   #define EXAMPLE_FILE
   #include example.hdr

   func char VolumeLabel
   param value uint nDrive
   // Return volume label of a drive
   vardef
      char cLabel
      char cDrive
   enddef
   if nDrive == 0
      nDrive := curdrive()
   else
      nDrive--
   endif
   cDrive := chr( 'A' + nDrive )
   ? cDrive
   cLabel := ""
   if findfirst( cDrive + ":\*.*", FIND_VOLUME )
      cLabel := findfstr()
   endif
   return( cLabel )
   endfunc
   
   proc FileData
   param const char cFiles
   // Print file size, date and time
   ? "File name        Extension  Size Date         Time          Attribute"
   if findfirst( cFiles, FIND_ANYFILE )
      repeat
         ? findfstr():15, findfext():6, findfsize():9, ;
            findfdate():12, findftime():10, findfattr():5
      until .not. findnext()
   else
      ? "No files"
   endif
   endproc
   
   proc Test_findfirst
   ? "Volume name is", VolumeLabel( 0 )
   ?
   FileData( "*.*" )
   endproc

   proc main
   Test_findfirst()
   endproc

See Also: File attribute table findfattr() findfdate() findfext() findfsize() findfstr() findftime() findnext()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson