Page 1 of 1

How to open a directory?

Posted: Sat Sep 25, 2004 5:23 pm
by maxic
Probably LUA a script to open a directory and to receive the list of files?

Posted: Mon Sep 27, 2004 12:32 am
by myles
Something like this will allow the user to select from a list of files:

Code: Select all

	local infilename = LM.GUI.OpenFile("Select Input File")
	if (infilename == "") then
		return
	end

	local f = io.open(infilename, "r")
Regards, Myles.

Thanks, I am well familiar with this script

Posted: Mon Sep 27, 2004 8:19 am
by maxic
The list of files of a directory is necessary

As in other programs:

DIR

.
..
file1
file2
file3
..........
file(n)

I it need to import sequence of raster images

Posted: Mon Sep 27, 2004 8:07 pm
by Lost Marble
The Lua interface can't give you a directory listing, but consider this:

1. Bring up a file dialog and let the user pick the first file.
2. The user picks "image_001.jpg"
3. The Lua script then starts loading "image_002.jpg" "image_003.jpg" "image_004.jpg" etc.

Assuming the images are numbered in sequence, Lua can just open them one at a time. Instead of a directory listing, Lua can guess the next file's name based on the last one and just has to check whether each file exists or not.

Posted: Thu Sep 30, 2004 2:21 pm
by maxic
Thanks for good idea!
:D