PeterF Posted May 26, 2006 Share Posted May 26, 2006 I am trying to create a script (below) for users to backup their favorites (later some other stuff) in the event of a HDD failure. The script between the "-------" works ERROR free. But, as soon as I check for the OS and add IF...(ElseIF or Else)...EndIF, I get an error (during run Beta in SciTE). It says IF doesn't have a matching ENDIF, but references "FUNC". Do I have something out of place? Thanks, PeteF $OSVer = @OSVersion If $OSVer = "WIN_XP" Then ; ------------------------- Between the dashes works fiine START $UserNAME = @UserName $UserDIR = @UserProfileDir ; 1 ; Prompt the user to run the script - use a Yes/No prompt (4 - see help file) $answer = MsgBox(4, ""& $OSVer & "", "Do You Want to Copy Your Favorites to the Server?") ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then ;MsgBox(0, "ADP Backup Utility", "OK. Bye!") Exit EndIf ; 2 ;DirCreate("H:\FAV-BACKUP") ; 3 ;Yes _FileCopy2(""& $UserDIR & "\Favorites\*.*","H:\FAV-BACKUP\") Func _FileCopy2($fromFile,$tofile) Local $FOF_RESPOND_YES = 16 Local $FOF_SIMPLEPROGRESS = 256 $winShell = ObjCreate("shell.application") $winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES) EndFunc ; ---------------------------------- END ; Else ; I want to repeat the above Routine for WIN_98 ;If Win_98 ;Endif EndIf EXIT ; Finished! Link to comment Share on other sites More sharing options...
Developers Jos Posted May 26, 2006 Developers Share Posted May 26, 2006 Peter, you have an Func...EndFunc inside of a If...EndIf which isn't allowed. Here is your script when ran through Tidy... expandcollapse popup$OSVer = @OSVersion If $OSVer = "WIN_XP" Then ; ------------------------- Between the dashes works fiine START $UserNAME = @UserName $UserDIR = @UserProfileDir ; 1 ; Prompt the user to run the script - use a Yes/No prompt (4 - see help file) $answer = MsgBox(4, "" & $OSVer & "", "Do You Want to Copy Your Favorites to the Server?") ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then ;MsgBox(0, "ADP Backup Utility", "OK. Bye!") Exit EndIf ; 2 ;DirCreate("H:\FAV-BACKUP") ; 3 ;Yes _FileCopy2("" & $UserDIR & "\Favorites\*.*", "H:\FAV-BACKUP\") ;### Tidy Error: Level error -> "If" Not closed before Func statement. ;### Tidy Error: Level error -> "Func" cannot be inside any IF/Do/While/For/Case/Func statement. Func _FileCopy2($fromFile, $tofile) Local $FOF_RESPOND_YES = 16 Local $FOF_SIMPLEPROGRESS = 256 $winShell = ObjCreate("shell.application") $winShell.namespace ($tofile).CopyHere ($fromFile, $FOF_RESPOND_YES) EndFunc ;==>_FileCopy2 ; ---------------------------------- END ; Else ; I want to repeat the above Routine for WIN_98 ;If Win_98 ;Endif EndIf Exit ; Finished! SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
PeterF Posted May 26, 2006 Author Share Posted May 26, 2006 Well Jos, Thank you again. I must try this TIDY. That is a better returned message than I received. PeterF Link to comment Share on other sites More sharing options...
PeterF Posted May 26, 2006 Author Share Posted May 26, 2006 FUNC can't reside inside any of the conditionals I am familiar with. Is this a good use for the missing GOTO (FAQ)? Link to comment Share on other sites More sharing options...
Developers Jos Posted May 26, 2006 Developers Share Posted May 26, 2006 (edited) FUNC can't reside inside any of the conditionals I am familiar with.Is this a good use for the missing GOTO (FAQ)?Func...EndFunc is used for subroutines you regularly need. so in this case if you need to copy multiple files its easier to put that logic in its own Func...End, in stead of repeating the same code over and over again, which you then call by FuncName(Parameters).Don't think there is an relation to a Goto which is really used to jump around in a program. Edited May 26, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
PeterF Posted May 26, 2006 Author Share Posted May 26, 2006 That should keep me busy for a while. I will report back soon. Thank You. PeterF Link to comment Share on other sites More sharing options...
PeterF Posted May 26, 2006 Author Share Posted May 26, 2006 Only 15 minutes playing around with it. It worked like a charm. that TIDY utility works nice too, thanks. PeterF 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