LiquidFire Posted February 20, 2010 Share Posted February 20, 2010 Hi,Recently I upgraded to the latest version of AutoIt (the one I was using was at least half a year old, not sure which one it was exactly). My code runs fine with the new version, but I noticed a change in behaviour when opening files for writing.Some of my scripts open a log file and periodically write to it. With the latest version of AutoIt, while the file is open for writing I can't open it (even read-only) with another program.A simple demonstration of the problem:Local $file = FileOpen("test.txt", 1) FileWriteLine($file, "1") Sleep(10000) ; while it's waiting, try to open the file with e.g. notepad - it will say it's being used by another process FileWriteLine($file, "2") FileClose($file)This makes it impossible to look at my log files until the script has finished running. Is there any way to open the file for writing without locking it?The only reason I updated to the latest version was so I could use FileFlush, but that's useless if I can't look at the file at all!Any help is appreciated. Link to comment Share on other sites More sharing options...
jchd Posted February 20, 2010 Share Posted February 20, 2010 There was a recent discussion about this issue. I personnally believe this is a regression due to changed flags within FileOpen. Developpers could consider looking closer to the issue if people affected would comment again on the existing (similar but not identically phrased) ticket. See this thread. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
LiquidFire Posted February 20, 2010 Author Share Posted February 20, 2010 Thanks for the response. I'll go comment on the bugs. Do you know of any workarounds currently? I guess I could just downgrade to 3.3.2.0 since it has FileFlush, but supposedly doesn't yet have this "bug fix". Link to comment Share on other sites More sharing options...
jchd Posted February 20, 2010 Share Posted February 20, 2010 That's the whole extent of my knowledge. Perhaps v3.3.2.0 will be fine for you in the interim. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Bowmore Posted February 20, 2010 Share Posted February 20, 2010 You could use a text file editor/viewer that is capable of opening files in read mode that other applications have locked for writing. TextPad and UltraEdit are 2 of many that come to mind. Notepad needs to be able to lock a file before it will open it. "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
LiquidFire Posted February 21, 2010 Author Share Posted February 21, 2010 Nothing seems to be able to open the file while it's opened for writing (and I need to be able to read it from a Python script, not a text editor anyway). However, I posted a comment in the bug tracker and apparently it works again in the latest betas (since 3.3.5.3). Link to comment Share on other sites More sharing options...
picaxe Posted February 21, 2010 Share Posted February 21, 2010 Look at _WinAPI_CreateFile($sFile, 2, 2, 6) ; open for read, $iAccess=r, $iShare=r+w and _WinAPI_SetFilePointer _WinAPI_ReadFile Link to comment Share on other sites More sharing options...
LiquidFire Posted February 21, 2010 Author Share Posted February 21, 2010 (edited) Thanks for the suggestions, picaxe. The resulting file handle wouldn't work with AutoIt's File* functions though, would it? I think I'll just use the beta or older version where this isn't a problem, rather than rewrite my code to use WinAPI directly. Edited February 21, 2010 by LiquidFire Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now