Thatsgreat2345 Posted May 5, 2006 Share Posted May 5, 2006 u probaly didnt copy the $ variable thats why Link to comment Share on other sites More sharing options...
meetrix Posted May 5, 2006 Author Share Posted May 5, 2006 what do you mean?u probaly didnt copy the $ variable thats why Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted May 5, 2006 Share Posted May 5, 2006 (edited) on the $file = BLAH u didnt copy the $ so it was just File = BLAH meaning its not being defined as a variable READ THE HELP FILE ON VARIABLES SERIOUSLY MAN JUST DO IT Edited May 5, 2006 by thatsgreat2345 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 5, 2006 Moderators Share Posted May 5, 2006 what do you mean?You have file =Not $file = is what he means. 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...
meetrix Posted May 5, 2006 Author Share Posted May 5, 2006 Sorry wrong copy and paste. I have fix it, but the only msg I get is "File Opened"n but the V:\123456789.log is still empty. You have file =Not $file = is what he means. Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted May 5, 2006 Share Posted May 5, 2006 (edited) DELETE THE CURRENT 123456789.log and then run it ok have fun enjoy NOW JUST TO INFORM YOU THIS ISNT GOING TO COPY AND PASTE EVERY SINGLE TIME, IF THE 123456789.log IS IN THE V DRIVE THEN ITS not GOING TO COPY JUST GOING TO SAY THAT IT OPENED THE FILE. Edited May 5, 2006 by thatsgreat2345 Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 5, 2006 Share Posted May 5, 2006 When I add EndIF at the end and run the script. I receive the Msg "The File Opened". $file = FileOpen("v:\123456789.log", 1) ; Check if file opened for reading OK If $file = -1 Then If Not FileCopy("c:\test.log", "v:\123456789.log", 1) Then MsgBox(16, "Debug", "Error on file copy!") Else MsgBox(64, 'Info:', 'File Copied') Exit EndIf Else MsgBox(64, 'Opened', 'The File opened') EndIf FileClose($file) We are back to my earlier question - Is the file empty before you run your script? If V:123456789.log exists and is empty, it gets opened, then immediately closed, and that's the end of your script. So the file is still there - and still empty! Nothing in the script you showed us writes anything to the file. Try this: $file = FileOpen("v:\123456789.log", 1) ; Check if file opened for reading OK If $file = -1 Then If Not FileCopy("c:\test.log", "v:\123456789.log", 1) Then MsgBox(16, "Debug", "Error on file copy!") Else MsgBox(64, 'Info:', 'File Copied') Exit EndIf Else MsgBox(64, 'Opened', 'The File opened') If Not FileWriteLine($file, @Hour & ":" & @MIN & ":" & @SEC & " - Wrote to file.") Then MsgBox(16, "Debug", "Error writing to file!") EndIf FileClose($file) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
meetrix Posted May 5, 2006 Author Share Posted May 5, 2006 Yes, the file is empty. That's why I want to copy to results from log on C: to the empty log fiel on drive(example=V). I will try it and let you know. Thanks We are back to my earlier question - Is the file empty before you run your script? If V:123456789.log exists and is empty, it gets opened, then immediately closed, and that's the end of your script. So the file is still there - and still empty! Nothing in the script you showed us writes anything to the file. Try this: $file = FileOpen("v:\123456789.log", 1) ; Check if file opened for reading OK If $file = -1 Then If Not FileCopy("c:\test.log", "v:\123456789.log", 1) Then MsgBox(16, "Debug", "Error on file copy!") Else MsgBox(64, 'Info:', 'File Copied') Exit EndIf Else MsgBox(64, 'Opened', 'The File opened') If Not FileWriteLine($file, @Hour & ":" & @MIN & ":" & @SEC & " - Wrote to file.") Then MsgBox(16, "Debug", "Error writing to file!") EndIf FileClose($file) Link to comment Share on other sites More sharing options...
MHz Posted May 5, 2006 Share Posted May 5, 2006 If you actually want to read the log and append to the other, then you could try the code below. ; Open file for read $file_source = FileOpen('c:\test.log', 0) If $file_source = -1 Then MsgBox(0x10, '', 'FileOpen Read Error') Exit 1 EndIf ; Open file file append write $file_destination = FileOpen('v:\123456789.log', 1) If $file_destination = -1 Then MsgBox(0x10, '', 'FileOpen Write Error') FileClose($file_source) Exit 2 EndIf ; Read the file and write it $content = FileRead($file_source, FileGetSize('c:\test.log')) If Not @error Then If FileWrite($file_destination, $content) Then MsgBox(0x40, '', 'Log written', 5) Else MsgBox(0x10, '', 'File Write Error') EndIf Else MsgBox(0x10, '', 'File Read Error') EndIf ; Close the file handles FileClose($file_source) FileClose($file_destination) Link to comment Share on other sites More sharing options...
meetrix Posted May 5, 2006 Author Share Posted May 5, 2006 I will try this. Thank you. I realize I have much to learn. Thanks again for everyones help. I will let you know if this works. If you actually want to read the log and append to the other, then you could try the code below. ; Open file for read $file_source = FileOpen('c:\test.log', 0) If $file_source = -1 Then MsgBox(0x10, '', 'FileOpen Read Error') Exit 1 EndIf ; Open file file append write $file_destination = FileOpen('v:\123456789.log', 1) If $file_destination = -1 Then MsgBox(0x10, '', 'FileOpen Write Error') FileClose($file_source) Exit 2 EndIf ; Read the file and write it $content = FileRead($file_source, FileGetSize('c:\test.log')) If Not @error Then If FileWrite($file_destination, $content) Then MsgBox(0x40, '', 'Log written', 5) Else MsgBox(0x10, '', 'File Write Error') EndIf Else MsgBox(0x10, '', 'File Read Error') EndIf ; Close the file handles FileClose($file_source) FileClose($file_destination) 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