Contents of a folder?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
TodayIsTheDay
Posts: 56
Joined: Sat Jun 20, 2009 2:41 pm

Contents of a folder?

Post by TodayIsTheDay » Wed Sep 30, 2009 2:33 am

I can open a text file that's in a folder, read it's contents, then put that into a text box...

Is there a way to fill a text box with the file names that are in a folder?

If all the files in that folder are text files, is there a way to go through each file, open, read and then load the contents of each into a text box?

Thanks!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Wed Sep 30, 2009 2:47 am

See the RevTalk Dictionary entry for "files" function, which returns a return-delimited list of the contenst of the working directory. You can save the current directory, change it to what you need, get "the files", and change it back, a la:

Code: Select all

function FileList pPath
  put the directory into tSaveDir
  set the directory to pPath
  put the files into tFiles
  set the directory to tSaveDir
  return tFiles
end FileList
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply