muncherw Posted October 29, 2008 Posted October 29, 2008 (edited) If my file doesn't exist I want my script to quit running. I *thought* that was what I coded, however when 'E:\results-1.htm' is missing I get the correct message but then it goes to the next part of the code. What am I doing wrong? ;check for jump drive if NOT FileExists("E:\results-1.htm") then MsgBox(0, "ERROR!", "E:\results-1.htm dos not exist!") Exit EndIf ;upload the file to the website, replacing the current file $foo = FileCopy("E:\results-1.htm", $webPath & $file, 1) if $foo = 0 then MsgBox(0, "ERROR!", "Backup not created") Exit EndIf MsgBox(0, $file, "upload complete") Edited October 30, 2008 by muncherw Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]
PsaltyDS Posted October 29, 2008 Posted October 29, 2008 If my file doesn't exist I want my script to quit running. I *thought* that was what I coded, however when 'E:\results-1.htm' is missing I get the correct message but then it goes to the next part of the code. What am I doing wrong? ;check for jump drive if NOT FileExists("E:\results-1.htm") then MsgBox(0, "ERROR!", "E:\results-1.htm dos not exist!") Exit EndIf ;upload the file to the website, replacing the current file $foo = FileCopy("E:\results-1.htm", $webPath & $file, 1) if $foo = 0 then MsgBox(0, "ERROR!", "Backup not created") Exit EndIf MsgBox(0, $file, "upload complete") There is no way for that code to show the "does not exist" message and then NOT exit. So either you are misinterpreting what is happening or this is not the code you are running. 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
FaT3oYCG Posted October 29, 2008 Posted October 29, 2008 ;check for jump drive if FileExists("C:\test.txt") = 0 then MsgBox(0, "ERROR!", "C:\test.txt does not exist!") Exit EndIf ;upload the file to the website, replacing the current file $foo = FileCopy("C:\test.txt", "C:\text backup.txt", 1) if $foo = 0 then MsgBox(0, "ERROR!", "Backup not created") Exit EndIf MsgBox(0, "C:\test.txt", "upload complete") i have just tested that and it works perfectly, maybe your computer is injecting itself while your not looking, it can happen Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right.
PsaltyDS Posted October 29, 2008 Posted October 29, 2008 ...maybe your computer is injecting itself while your not looking, it can happen Code injection... with dirty needles... that's how computers get viruses. 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
Valuater Posted October 29, 2008 Posted October 29, 2008 (edited) I would write it more like this... *** NOT TESTED ;check for file If Not FileExists("C:\test.txt") Then MsgBox(0, "ERROR!", "C:\test.txt does not exist!") Else; copy file If FileCopy("C:\test.txt", "C:\text backup.txt", 1) Then MsgBox(0, "C:\test.txt", "upload complete") Else; If copy fails MsgBox(0, "ERROR!", "Backup not created") EndIf EndIf Exit However, as noted by Salty, this is not related to a website upload 8) Edited October 29, 2008 by Valuater
muncherw Posted October 30, 2008 Author Posted October 30, 2008 There is no way for that code to show the "does not exist" message and then NOT exit. So either you are misinterpreting what is happening or this is not the code you are running. Coming at it today with a freshly rested brain I find that I was looking at the wrong lines of code. Before what I showed you was where I did the backup which obviously comes before the Exit function. I showed the code after it thinking it (which is quite similar but not the same) thinking it was the other section. Silly mistake...maybe when I'm not looking the computer was injecting *me* with dirty code! Thanks everybody. Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]
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