CFileList:new


The new method creates an instance of the CFileList class. You must call new before using any class methods or properties. Note that this object can also be created using the new_filelist function. Use the Next method to iterate over the file list, fetching the names of each file from the list.

Syntax

F = CFileList:new()

bullet.gif    Creates a new object. Using this constructor, you must call Open before fetching files from the filelist.

F = CFileList:new( sFileName )

bullet.gif    Creates a new CFileList object and opens the file list from sFileName. The file name must include a complete path specification.

F = CFileList:new( CFileList_Object )

bullet.gif    Creates a new CFileList object by copying the properties of the existing CFileList_Object.

Remarks

Three overloads are provided for this method. If you use the default constructor with no arguments, then Open must be called to open the file list from a file. If the file name is specified, the file list is opened and set to the beginning of the file. If another CFileList object is specified, then it is copied into the curent CFileList. Note that Next returns the next file name as a string, so you should not hide its return value by using it as a loop counter.

Example

The following script lists files inside the folder specified by the string sFolder.

F = CFileList:new( sFileName )

-- Create a new CFileList object

for n = 1, F:Count() do

-- step through the files

  Printf("%s\r\n", F:Next() )

-- list the next file name

end

 

Related Topics

CFileList, delete, new_filelist, Next


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.