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!
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.
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
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
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.