FF.Open

Previous  Next

 

hHandle = FF.Open( BaseFolder AS STRING,

                   FileMask   AS STRING = "*.*",

                   SubFolders AS INTEGER = FALSE,

                   Sort       AS INTEGER = EL_FF_SORT_Ascending,

                   UseDirExt  AS INTEGER = FALSE ) AS HANDLE

 


 

Opens a new File Finder for the specified folder and returns a handle to it.  If failed, it will return -1 (MB_INVALID_HANDLE).  By default, the finder will search all files.  The FileMask parameter can contain multiple masks separated by a semicolon.  Example "*.bas;*.bis".

 

The following Search Options are defined in MyBASIC2_ExtLib.BIS

 

' File Finder Sorting Options

CONST EL_FF_SORT_None            = 0

CONST EL_FF_SORT_Ascending       = 1

CONST EL_FF_SORT_Descending      = 2

 

Example:

 

OPTION BASE 1

 

$LIBRARY "MyBASIC2_ExtLib"

$INCLUDE "MyBASIC2_ExtLib"

 

DIM hFF AS HANDLE

DIM nFiles AS INTEGER

DIM i AS INTEGER

DIM tmpFile AS STRING

 

CLS

 

' Folder to Search

CONST cFolder = "D:\Tech\Projects\COMMON\MyBASIC2\CodeTemplates"

 

' Open the File Finder and search for Code Template files

hFF = FF.Open( cFolder, "*.ct2", TRUE )

 

' Find all "normal" files

nFiles = FF.Find( hFF, EL_FF_NormalFiles )

 

' Print Result of Search

FOR i = 1 TO nFiles

  PRINT FF.GetFilePath( hFF, i ),

ENDFOR

 

PRINT ,

PRINT "Total File(s) "; FF.GetFileCount( hFF ),

 

' Close the File Finder

FF.Close( hFF )

 

END