|
crlanglois Newbie
Joined: 12 May 2010 Posts: 4
|
Posted: Tue Jun 15, 2010 3:44 pm
Verify file exists or another suggestion? |
Hi,
My problem is this. I want to launch an external process and wait for it to complete in order to continue. As far as I can tell cmud doesn't handle external threads so what I'm doing is deleting a flag file, launching the process, and having the other process create a flag file when it is done.
Within CMUD I want to have it run a While statement with a delay and continually check whether this flag file exists or not. Once the file exists, it exits the while loop and continues. My problem is as far as I can tell there is no command within Cmud that will check whether a file exists without opening it, also as far as I can tell the #file command will create the file if it does not exist if I open it for a read. This is problematic as I don't want the file to be created if it does not exist.
If my flag file solution is not doable, can anyone recommend another way to handle my problem? I am writing the other program as well in another scripting language so my level of freedom to do what I wish here is high.
Thanks. |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Tue Jun 15, 2010 3:58 pm |
You could trying doing #READ and if you get no result with data in your file. If you get no result then you know the file isn't there. Alternatively you can try using COM to communicate with your external program.
|
|
_________________ Asati di tempari! |
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Tue Jun 15, 2010 4:37 pm |
Use vbscript or lua as the script language.
vb:
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("C:\flagfile.txt") Then
' do x
Else
' do y
End If
lua:
function exists(n)
local f=io.open(n)
io.close(f)
return f==nil
end |
|
_________________ Taz :) |
|
|
|
|
|