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
-
fhx
- Posts: 6
- Joined: Wed Jul 09, 2008 7:22 pm
Post
by fhx » Tue Jul 15, 2008 12:49 am
Greeting,
I am new to revolution. so, my apologies if this is a stupid question:
I need to create an event as soon as a new file has been written in a specific directory (content written and file closed). Is there any other approach than having a function that is looking periodically (means every 1 sec or shorter) in this specific directory.
I was hoping to have something like:
Code: Select all
on newFile in the directory
...
end newFile
Any suggestions/hints or even code-snippets?
Thanks and best,
Frank
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Tue Jul 15, 2008 10:39 am
Hi Frank,
In Mac OS X, you could use a folder action. In Linux, a deamon might do the trick.
I'm not sure about Windows. There might be something similar to folder actions.
What about using a command line instruction to send files to a standalone, or simply drop the files onto the standalone, and have the standalone handle the files and put them into a different folder afterwards (or delete them)?
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
Tim
- Posts: 29
- Joined: Wed Oct 31, 2007 12:56 pm
Post
by Tim » Tue Jul 15, 2008 11:23 am
Hey Frank,
Here is some code that will monitor a folder - I've written it so it all goes in the script of a button at the moment :
Code: Select all
on mouseUp
send "monitorFolder C:\Users\Tim\Desktop" to me in 0 milliseconds
end mouseUp
local sFileList, sMonitoredFolder
on monitorFolder pFolder
put pFolder into sMonitoredFolder
send "updateMonitor" to me in 500 milliseconds
end monitorFolder
on updateMonitor
local tOldFolder
put the defaultFolder into tOldFolder
set the defaultFolder to sMonitoredFolder
if sFileList is empty then
put the long files into sFileList
end if
if the long files <> sFileList then
put the long files into sFileList
send "filesChanged" to me in 0 milliseconds
end if
set the defaultFolder to tOldFolder
send "updateMonitor" to me in 500 milliseconds
end updateMonitor
-- You would write this handler to do whatever you wanted to do
-- when something in the folder changes.
on filesChanged
put the long time & " : Some files have changes in the monitored folder" & return after msg
end filesChanged
Hope this helps as a starting point.
Tim.
-
fhx
- Posts: 6
- Joined: Wed Jul 09, 2008 7:22 pm
Post
by fhx » Tue Jul 15, 2008 3:38 pm
Thanks,
this really helped.
Best,
Frank
-
Garrett
- Posts: 386
- Joined: Sat Apr 08, 2006 8:15 am
-
Contact:
Post
by Garrett » Tue Jul 15, 2008 7:21 pm
Keep in mind though that trying to find out if the file is still in use may be near impossible natively within Rev. If you need to find out if the file is still in use by another program you may have to seek command line alternatives for that info and use Rev to run the command line app and get it's info.