meetrix Posted May 5, 2006 Share Posted May 5, 2006 I have this simple script that should work, but it's not.. it's the little things that kill. $file = FileOpen("v:\123456789.log", 1) ; Check if file opened for reading OK If $file = -1 Then FileCopy("c:\test.log", "v:\123456789.log",1) Exit EndIf FileClose($file) Let me know.. Thank you in advance for all your help Me Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted May 5, 2006 Share Posted May 5, 2006 i dont see the problem?, your opening a file, if the file isnt open then it will copy test.log from C into your V drive.... then exit Link to comment Share on other sites More sharing options...
meetrix Posted May 5, 2006 Author Share Posted May 5, 2006 Well, that's what I thought, but for some wierd reason, when I open the V:\123456789.log file it's empty. I don't understand. Any other thoughts?I have this simple script that should work, but it's not.. it's the little things that kill.$file = FileOpen("v:\123456789.log", 1); Check if file opened for reading OKIf $file = -1 Then FileCopy("c:\test.log", "v:\123456789.log",1) ExitEndIfFileClose($file)Let me know.. Thank you in advance for all your helpMe Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted May 5, 2006 Share Posted May 5, 2006 (edited) Ok 1. Make sure all cases are the Same or else its not going to copy correctly. 2. Make sure your using the correct paramater on the FileCopy 0 = (default) do not overwrite existing files 1 = overwrite existing files 8 = Create destination directory structure if it doesn't exist (See Remarks). 9 = Create destination and Overwrite existing File If that doesnt work then , a work around would be doing a Fileread, and then do a _filecreate and then a filewrite. 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 Well, that's what I thought, but for some wierd reason, when I open the V:\123456789.log file it's empty. I don't understand. Any other thoughts? Is 123456789.log or test.log empty before you run the run the script? And you might want to test the result of the FileCopy() because you only do it if the FileOpen() fails, so things are going wrong already: $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!") Exit EndIf FileClose($file) Hope that helps... 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...
Thatsgreat2345 Posted May 5, 2006 Share Posted May 5, 2006 no he had it right if it didnt open then he wanted it to copy thats exactly the point of the -1 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 5, 2006 Moderators Share Posted May 5, 2006 (edited) no he had it right if it didnt open then he wanted it to copy thats exactly the point of the -1That doesn't make much sense. If it failed it's probably in use, which means you would have to use FileMove() / Rename, I would imagine. Edited May 5, 2006 by SmOke_N 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...
Thatsgreat2345 Posted May 5, 2006 Share Posted May 5, 2006 if it failed it could mean it wasnt there thus he would do a filecopy Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 5, 2006 Moderators Share Posted May 5, 2006 if it failed it could mean it wasnt there thus he would do a filecopyWell if that's the case, I would think that If Not FileExists() Then would be a better alternative. 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...
Thatsgreat2345 Posted May 5, 2006 Share Posted May 5, 2006 yes i know but i was just giving the guy props no need to hate hehehe Link to comment Share on other sites More sharing options...
meetrix Posted May 5, 2006 Author Share Posted May 5, 2006 I just tried your suggestion, but it did not work. ????? Is 123456789.log or test.log empty before you run the run the script? And you might want to test the result of the FileCopy() because you only do it if the FileOpen() fails, so things are going wrong already: $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!") Exit EndIf FileClose($file) Hope that helps... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 5, 2006 Moderators Share Posted May 5, 2006 Did you get the msgbox? Why don't you explain what you actually want to do, maybe we have an easier way of doing it. 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 no. I did not...Did you get the msgbox?Why don't you explain what you actually want to do, maybe we have an easier way of doing it. Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted May 5, 2006 Share Posted May 5, 2006 he probaly didnt get the message box cuz its already created Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 5, 2006 Moderators Share Posted May 5, 2006 no. I did not...Try this and tell us what message box you got, and you still need to tell us what you are actually trying to do:$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 Else MsgBox(64, 'Opened', 'The File opened') EndIf FileClose($file)You will get a MsgBox(). 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 The purpose of this script is: There is a customer application that creates a log file on the C: drive. I want to create a log file on the Server and copy the results file from drive C: to (for Example, drive V:). Then print, but this step is already taken care off thanks to the autoit support group. I received the following error message. C:\Program Files\AutoIt3\Examples\Helpfile\FileCopy.au3(10,1) : ERROR: missing EndIf. Else ^ C:\Program Files\AutoIt3\Examples\Helpfile\FileCopy.au3(5,64) : REF: missing EndIf. If Not FileCopy("c:\test.log", "v:\123456789.log", 1) Then ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Program Files\AutoIt3\Examples\Helpfile\FileCopy.au3 - 1 error(s), 0 warning(s) 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) Try this and tell us what message box you got, and you still need to tell us what you are actually trying to do:$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 Else MsgBox(64, 'Opened', 'The File opened') EndIf FileClose($file)You will get a MsgBox(). Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted May 5, 2006 Share Posted May 5, 2006 nice try smoke u forgot an endif , jeesh just cleaning up your mistakes tonight, first the guictrlsetdata and now this ahhaha $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) Link to comment Share on other sites More sharing options...
nfwu Posted May 5, 2006 Share Posted May 5, 2006 Tiny mistake on SmOke_N's part: Exit should be EndIf. Corrected: $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') EndIf Else MsgBox(64, 'Opened', 'The File opened') EndIf FileClose($file) #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 5, 2006 Moderators Share Posted May 5, 2006 Tiny mistake on SmOke_N's part:Exit should be EndIf.Corrected:#)Thanks, that's what I get for typing in the Fast Reply window lol. 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 This is the error I get: C:\Program Files\AutoIt3\Examples\Helpfile\FileCopy.au3(1,6) : ERROR: syntax error file = ~~~~~^ C:\Program Files\AutoIt3\Examples\Helpfile\FileCopy.au3 - 1 error(s), 0 warning(s) Tiny mistake on SmOke_N's part: Exit should be EndIf. Corrected: $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') EndIf Else MsgBox(64, 'Opened', 'The File opened') EndIf FileClose($file) #) 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