ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / External file functions
  • Finding out the number of read-only ".TXT" files
  • Finding out the number of read-only "*.DOC" files
fListFile (Example)
Finding out the number of read-only ".TXT" files
WINDEVJavaUser code (UMC)
The following code is used to find out the number of read-only ".TXT" files found in a directory selected by the user. The directory is selected by fSelectDir.
// Declare and initialize the variables
 
// Number of files matching the criteria
NbROFiles is int
// Number of "*.TXT" files
NbTXTFiles is int  
NbTXTFiles = 0
SearchCriterion is string
 
// Select the directory in which the files will be listed
SearchCriterion = fSelectDir("", "Select a directory", ...
"Finding the .TXT files in the selected directory")
 
// Add the "\*.TXT" criterion at the end of the name of the selected directory
SearchCriterion = SearchCriterion + "\*.TXT"
 
// List the "*.TXT" files
NbTXTFiles = 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, NbTXTFiles)
// Declare the variable
NbROFiles is int
// Read-only files?
IF Position(fAttribute(Directory + Name), "R") <> 0 THEN
  Transfer(&NbROFiles, NbTXTFiles, 4)
  NbROFiles++
  Transfer(NbTXTFiles, &NbROFiles, 4)
  // Display the name of the file in "LIST_FileList"
  ListAdd(LIST_FileList, Directory + Name)
END
RETURN True
Finding out the number of read-only "*.DOC" files
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 08/22/2022

Send a report | Local help