AuxMax Posted December 21, 2005 Share Posted December 21, 2005 Newbie here....first post. Have figured out most of my issues previously, but this one doesn't jive. I'm writing a script to upgrade an application. As part of the upgrade process, I have included error log creations in case the upgrade fails. Using _FileCreate, the log file name is the computer name (using @Computer) concatinated with the LOG extension. This part works.... However, when I try to FileWriteLine or FileWrite the canned error message, I get an empty file. Now, if I modify the code to simply create a static file name, like PC.log, it writes as expected. Huh? Here's the code: #include <file.au3> #include <date.au3> Dim $file $file = FileOpen ( '"c:\temp\" & @ComputerName & ".log"' , 2 ) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWriteLine( $file , "It's broke.") FileWriteLine( $file , "Date and Time:" & _Now()) FileClose($file) I have full rights to the temp directory. I've also tried other folders to no avail. Insight would be extremely helpful.... Link to comment Share on other sites More sharing options...
w0uter Posted December 21, 2005 Share Posted December 21, 2005 (edited) wrong quotes, this should work: $file = FileOpen ( "c:\temp\" & @ComputerName & ".log" , 2 ) OR $file = FileOpen (@tempdir & '\' & @ComputerName & '.log', 2) Edited December 21, 2005 by w0uter My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Valuater Posted December 21, 2005 Share Posted December 21, 2005 (edited) look up _FileWriteLog() in help 8) BTW Welcome to the forums Edited December 21, 2005 by Valuater Link to comment Share on other sites More sharing options...
MrSpacely Posted December 21, 2005 Share Posted December 21, 2005 PS you donot need File.au3 for Filewriteline() if using _Filewritelog you don't need Date.log Link to comment Share on other sites More sharing options...
AuxMax Posted December 22, 2005 Author Share Posted December 22, 2005 Thanks for the responses. wOuter was on the money with the quotes, however, I'll look at the _Filewritelog as well...thanks Valuator. Link to comment Share on other sites More sharing options...
guitara Posted January 4, 2006 Share Posted January 4, 2006 it should be noted that scite editor doesn't prompt you to include file.au3 if you use file operations. the exe compiles, runs, but the file operations don't happen. took me a while to figure out I hadn't included it. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 4, 2006 Moderators Share Posted January 4, 2006 it should be noted that scite editor doesn't prompt you to include file.au3 if you use file operations. the exe compiles, runs, but the file operations don't happen. took me a while to figure out I hadn't included it.Hmmm, I know that I test everything I do before I compile it in SciTe. And an error is thrown if I'm calling for a function that isn't either 'A' in the script or 'B' in one of the #include <> files. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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