How to open a directory?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
maxic
Posts: 64
Joined: Wed Sep 22, 2004 8:24 am
Location: Moscow, Russian Federation
Contact:

How to open a directory?

Post by maxic »

Probably LUA a script to open a directory and to receive the list of files?
myles
Posts: 821
Joined: Sat Aug 21, 2004 3:32 am
Location: Australia, Victoria, Morwell
Contact:

Post 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.
User avatar
maxic
Posts: 64
Joined: Wed Sep 22, 2004 8:24 am
Location: Moscow, Russian Federation
Contact:

Thanks, I am well familiar with this script

Post 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
User avatar
Lost Marble
Site Admin
Posts: 2347
Joined: Tue Aug 03, 2004 6:02 pm
Location: Scotts Valley, California, USA
Contact:

Post 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.
User avatar
maxic
Posts: 64
Joined: Wed Sep 22, 2004 8:24 am
Location: Moscow, Russian Federation
Contact:

Post by maxic »

Thanks for good idea!
:D
Post Reply