PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

New WINDEV, WEBDEV, WINDEV Mobile 25 feature!
  • Example of values that can be taken by
  • Complete interruption of fListFile
  • Partial interruption of fListFile (syntax 2)
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
WLanguage procedure called by fListFile
Procedure (also called "Callback) called by fListFile for each file found. It can be a local, global or internal procedure.
Example
// Finding out the number of read-only "*.DOC" files
// in a directory.
 
// Declare and initialize the variables
 
// Number of files matching the criteria
NbROFiles is int
// Number of "*.DOC" files
NbDocFiles is int
NbDocFiles = 0
SearchCriterion is string
 
// Select the directory in which the files will be listed
SearchCriterion = "C:\MyDocuments\"
 
// Add the "\*.doc" criterion at the end of the name of the selected directory
SearchCriterion = SearchCriterion + "\*.doc"
 
// List of "*.DOC" files
NbDocFiles = fListFile(SearchCriterion, "FileAttribute", &NbROFiles)
 
// Display the number of files matching the criteria
Info("There are" + NbROFiles + "read-only files out of" + ...
NbTXTFiles + "listed files")
 
// ---------------------------------------------------
 
// Local fListFile procedure
PROCEDURE FileAttribute(Directory, Name, Change, NbDocFiles)
// Declare the variable
NbROFiles is int
// Read-only files?
IF Position(fAttribute(Directory + Name), "R") <> 0 THEN
Transfer(&NbROFiles, NbDocFiles, 4)
NbROFiles++
Transfer(NbDocFiles, &NbROFiles, 4)
// Display the name of the file in "LIST_FileList"
ListAdd(LIST_FileList, Directory + Name)
END
RESULT True
Syntax
<Result> = fListFile_Callback(<Path> , <File name> [, <Change> [, <Procedure pointer>]])
<Result>: Boolean
  • True to continue browsing the files,
  • False to stop browsing the files.
<Path>: Character string
Path of file used (it always ends with a "\" character ; for example, "C:\WINDEV\").
<File name>: Character string
Name of file found.
<Change>: Optional Integer constant
Used to know if there was a directory change. The possible values are:
flFirstFileThe file is the first one listed in the <Path>.
flChangeDirThe file is the first one listed in a subdirectory of <Path> (this means that there was a change of directory).
flFileAll other cases.
<Procedure pointer>: Optional integer
Value passed in the <Pointer> of fListFile. If <Pointer> is not specified in fListFile, <Procedure pointer> is set to 0.
Remarks

Example of values that can be taken by <Change>

When browsing the files listed by fListFile, here are the different values that can be taken by <Change>:
Current file<Change>
Dir\File 1flFirstFile
Dir\File nflFile
Dir\SubDir 1\File 1flChangeDir
Dir\SubDir 1\File mflFile
Dir\SubDir 2\File 1flChangeDir
Dir\SubDir 2\File xflFile

Complete interruption of fListFile

As long as there are files to browse, fListFile cannot be interrupted.
To force the interruption of the complete browse, use the following line in the procedure:
RESULT False
For example, the "FindProduct" procedure is automatically called by fListFile:
PROCÉDURE FindProduct(Path, FileName)
...
// Stop requested?
Multitask(-1)
IF KeyPressed(kpEscape) = True THEN
Info("The search will be stopped")
RESULT False
END
...
RESULT True
In this case, fListFile returns the number of files browsed until the call to "RESULT False".
In any other case (to continue browsing), the procedure MUST return True.
An error is generated if the procedure returns no value (neither True nor False).

Partial interruption of fListFile (syntax 2)

To prevent the procedure from running for a given file, use the following line:
RESULT True
For example, the "FindProduct" procedure is automatically called by fListFile:
PROCÉDURE FindProduct(Path, FileName)
...
// File to ignore
IF FileName = "WrongFile.XLS" THEN
RESULT True
END
...
RESULT True
In this case, fListFile automatically calls the procedure for the next listed file.
An error is generated if the procedure returns no value (neither True nor False).
Business / UI classification : Neutral code
Component : wd250std.dll
Minimum version required
  • Version 25
This page is also available for…
Comments
Click [Add] to post a comment