ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / External file functions / WLanguage procedures
  • Example of values that can be taken by
  • Complete interruption of fListFile
  • Partial interruption of fListFile
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
WLanguage procedure called by fListFile
WLanguage procedure ("Callback") called by fListFile for each file found. This procedure 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
RETURN 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:
flChangeDirThe file is the first one listed in a subdirectory of <Path> (this means that there was a change of directory).
flFileAll other cases.
flFirstFileThe file is the first one listed in the <Path>.
<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>

The following are the different values that can be taken by <Change> when browsing the files listed by fListFile:
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:
PROCEDURE FindProduct(Path, FileName)
...
// Stop requested?
Multitask(-1)
IF KeyPressed(kpEscape) = True THEN
Info("The search will be stopped")
RESULT False
END
...
RETURN 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

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

Last update: 07/12/2022

Send a report | Local help