Jump to content

Open Handles


Recommended Posts

$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?

Link to comment
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")

#)

Link to comment
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

Link to comment
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..

Link to comment
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")

Link to comment
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

Link to comment
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?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...