CFileDlg:Next


The Next method returns the next file name in the list of names returned by the Open method. This is an iterator to fetch the next name in a list. The iteration must be started using the Start method.

Syntax

sFileName = CFileDlg:Next()

bullet.gif    sFileName is the returned path string for the file. When done, nil is returned.

Remarks

This method advances to the next file name and returns it. If another file name is found, the full path (machine, drive, folder, file name, and extension) is returned. If no more file names are found, nil is returned. The search must have been initialized using the Start method before Next is called. The returned file names might be used immediately or be stored in an indexed table for later use. The example below stores the values in an indexed table from which you can later fetch the n-th file name using FileName[i].

Example

The following example uses Next to loop over 100 files and store the returned file names in a table:

F = new_filedlg()

-- create a CFileDlg object

 

F.bSetMaxFiles = true

-- set the flag for selecting more than 1 file

F.nMaxFiles = 100

-- allow selecting up to 100 files

sName, bSuccess = F:Open()

-- get a file name

FileName = {}

-- create a table to hold the file names

n = 1

-- setup an index counter

F:Start()

-- initialize the file name iteration

while true do

-- loop until a nil file name is returned

  str = F:Next()

-- save the next file name

  if str == nil then break end

-- exit the loop when a nil file name is returned

  FileName[n] = str

-- save the file name in the table

  n = n + 1

-- increment the table index

end

 

-- next statement following the loop

 

Related Topics

CFileDlg class, Open, Start


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