Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
crlanglois
Newbie


Joined: 12 May 2010
Posts: 4

PostPosted: 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.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: 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!
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: 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 :)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net