PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • 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
WINDEVReports and QueriesWindows MobileJavaUser 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 via 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
RESULT True
Finding out the number of read-only "*.DOC" files
WEBDEV - Server codePHPAjax
The following code is used to find out the number of read-only "*.DOC" files found in a directory selected by the user.
// 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
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment