Sign in to follow this  
Followers 0
Qual-IT London

Open Handles

10 posts in this topic

$handle = fileopen(@tempdir & "\xyz\q.txt",1)

FileWriteLine(@TempDir & "\xyz\q.txt","test")

FileClose( $handle )

_RunDOS("mydosprog.bat")

now this would seem to work fine however when mydosprog tries to rename q.txt it gets a file is already open in another app message.

it seems that the file is not properly closed until autoIT exits

any ideas?

Share this post


Link to post
Share on other sites



1 solution:

;;;;;;;FILE WRITE.au3
$handle = fileopen(@tempdir & "\xyz\q.txt",1)
FileWriteLine(@TempDir & "\xyz\q.txt","test")
FileClose( $handle )
Exit

;;;;;;;;APP.au3
;AutoIt3 does not need to be installed for this run command to work. (assuming you have compilied this file)
Run(@AutoItEXE & " /AutoIt3ExecuteScript "&'"file write.au3"')
_RunDOS("mydosprog.bat")

#)

Share this post


Link to post
Share on other sites

1 solution:

;;;;;;;FILE WRITE.au3
$handle = fileopen(@tempdir & "\xyz\q.txt",1)
FileWriteLine(@TempDir & "\xyz\q.txt","test")
FileClose( $handle )
Exit

;;;;;;;;APP.au3
;AutoIt3 does not need to be installed for this run command to work. (assuming you have compilied this file)
Run(@AutoItEXE & " /AutoIt3ExecuteScript "&'"file write.au3"')
_RunDOS("mydosprog.bat")

#)

yeh sure why not! well thought of! shame it will add another 250k compressed to the size of the distribution

thats the only prob with AutoIT the massive overhead of the engine that goes with the script

Share this post


Link to post
Share on other sites

sorry i see what you mean (im really tired this project has been dragging on for weeks)

dont compile the 4 lines of text

could be done like this. would be better if AutoIT just closed the file i asked it to close properly!

but maybe like this..

Share this post


Link to post
Share on other sites

Note: Do not mix filehandles and filenames, i.e., don't FileOpen a file and then use a filename in this function.Either use filehandles or filenames in your routines--not both.

Use the handle for FileWriteLine also.

$handle = fileopen(@tempdir & "\xyz\q.txt",1)

FileWriteLine($handle, "test")

FileClose( $handle )

_RunDOS("mydosprog.bat")

Share this post


Link to post
Share on other sites

Use the handle for FileWriteLine also.

sadly for some reason that still doesn't work!

maybe i'll try the other idea calling another autoit script

Share this post


Link to post
Share on other sites

I have a felling that autoit is not the real culprit here (I do not know the internals). I have had the same problem in C when using the native MS Windows file commands. If I recall right the solution was to do a FileFlushBuffers(hFile) (win32 api call) even when it was no real reason to do so.

Regards

Uten

Share this post


Link to post
Share on other sites

I have a felling that autoit is not the real culprit here (I do not know the internals). I have had the same problem in C when using the native MS Windows file commands. If I recall right the solution was to do a FileFlushBuffers(hFile) (win32 api call) even when it was no real reason to do so.

Regards

Uten

is that possible with AutoIT?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0