Jump to content

End Func Syntax Error


fu2m8
 Share

Recommended Posts

Hi everyone. I am having a bit of trouble with a script i am writing which function is too copy a template default user profile (that has allready been set up) to C:\Documents and Settings\Default User. I had the core of the program working great but i wanted to extend it a bit so instead of prompting the user for the settings everytime it only does it once and writes the settings to an INI file and reads it from there the next time the program is run. The problem is when i do an AutoIT Syntax check in Scite it comes up with these errors:

>"C:\Program Files\AutoIt3\SciTe\au3check\au3check" "E:\AutoIT Scripts\Default Profile Copier\Default Profile Copier.au3"

AutoIt3 Syntax Checker v1.07, Copyright © Tylo, 2004

E:\AutoIT Scripts\Default Profile Copier\Default Profile Copier.au3

E:\AutoIT Scripts\Default Profile Copier\Default Profile Copier.au3(59,4) : ERROR: syntax error

EndFunc

~~~^

E:\AutoIT Scripts\Default Profile Copier\Default Profile Copier.au3(63,1) : ERROR: syntax error

Func

^

E:\AutoIT Scripts\Default Profile Copier\Default Profile Copier.au3(73,1) : ERROR: syntax error

EndFunc

^

E:\AutoIT Scripts\Default Profile Copier\Default Profile Copier.au3(77,1) : ERROR: syntax error

Func

^

E:\AutoIT Scripts\Default Profile Copier\Default Profile Copier.au3(91,4) : ERROR: syntax error

EndFunc

~~~^

E:\AutoIT Scripts\Default Profile Copier\Default Profile Copier.au3(95,1) : ERROR: syntax error

Func

^

E:\AutoIT Scripts\Default Profile Copier\Default Profile Copier.au3(115,4) : ERROR: syntax error

EndFunc

~~~^

E:\AutoIT Scripts\Default Profile Copier\Default Profile Copier.au3(10,17) : ERROR: delete(): undefined function.

delete()

~~~~~~~~~~~~~~~~^

E:\AutoIT Scripts\Default Profile Copier\Default Profile Copier.au3(72,14) : ERROR: create(): undefined function.

create()

~~~~~~~~~~~~~^

E:\AutoIT Scripts\Default Profile Copier\Default Profile Copier.au3(84,15) : ERROR: copy(): undefined function.

copy()

~~~~~~~~~~~~~~^

>Exit code: 2 Time: 0.221

These errors only came up recently but i can't work out what ive done to make this happen and ive had a look in the helpfile but couldn't really find anything that explains why this would happen.

Heres the code ive got so far and if anyone has a chance if they could give us a hand in solving this problem it would greatly be appreciated.

;This program will attempt to copy the default profile from a specified location to C:\Documents and Settings\Default User

;Creates a function called 'autorun' which checks the 'settings.ini' file for the 'autorun' key to see wether or not the program should automatically run through or prompt for a location to copy from

Func autorun()
  ;Creates a variable to check wether to autorun
   $autorunVAR = IniRead("settings.ini", "dpc", "autorun", "0")
     ;Checking for the settings, if the 'autorun' setting = YES the program skips to the 'delete' function to automatically copy the profile
      If $autorunVAR = "YES" Then
         delete()
      EndIf
     ;If the 'autorun' setting = NO then it proceeds to the 'location' function
      If $autorunVAR = "NO" Then
         location()
      EndIf
     ;If the 'autorun' setting = 0 then something is really wrong and maybe it couldn't find the 'settings.ini' file, displays a msg saying so and quits the program
      If $autorunVAR = 0 Then
         MsgBox(48, "Error", "The setting could not be correctly read from the 'settings.ini' file. It may not exist or has not been properly configured. The program will now exit.")
         Exit
      EndIf
EndFunc

;Creates a function called 'location' which prompts the user for the location of the template default user profile

Func location()
  ;Prompts the user for the location of their default user profile template
   $locationVAR = FileSelectFolder("Please select the location of your template default user directory...", "", "")
     ;If the user cancels/closes the window then the program exits and dispalys a message saying so
      If @error = 1 Then 
         MsgBox(48, "Error", "You closed the window, the program will now exit. If you wish to copy the profile at a later time then please run the program again.")
         Exit
      EndIf
  ;Writes the location that the user selected to the 'settings.ini' file 
   $locationINI = IniWrite("settings.ini", "dpc", "location", $locationVAR)
     ;If it was unsucessful then a MsgBox is displayed saying so
      If $locationINI = 0 Then
         MsgBox(48, "Error", "The program was unable to write to the 'settings.ini' file. Perhaps it is read only? Please check it and try again.")
         Exit
      EndIf
  ;Creates a varaible that asks the user if they want the program to automatically run next time without the prompts
   $autorunINI = MsgBox(36, "AutoRun Next Time?", "Would you like the program to automatically run next time? If you choose Yes you will not be prompted for the location of the default user template directory. If you choose no then the next time the program is run you will have to select the location of the default user template directory.")
     ;If the user hits Yes then the program puts that setting in the 'settings.ini' file
      If $autorunINI = 6 Then
         $autorunINIcheckYES = IniWrite("settings.ini", "dpc", "autorun", "YES")
           ;If there was an error it is displayed
            If $autorunINIcheckYES = 0 Then
               MsgBox(0, "Error", "The program was unable to save your settings to the 'settings.ini' file, it may be read-only or not exist. The program will now exit.")
               Exit
            EndIf
     ;If the user hits No then the program puts that setting in the 'settings.ini' file
      If $autorunINI = 7 Then
         $autorunINIcheckNO = IniWrite("settings.ini", "dpc", "autorun", "NO")
           ;If there is an error it is displayed
            If $autorunINIcheckNO = 0 Then
               MsgBox(0, "Error", "The program was unable to save your settings to the 'settings.ini' file, it may be read-only or not exist. The program will now exit.")
               Exit
            EndIf
      EndIf
   EndFunc

;Creates a function called 'delete' that deletes the default user directory

Func delete()
  ;Creates a variable that removes the default user directory
   $dirremoveVAR = DirRemove("C:\Documents and Settings\Default User", 1)
     ;Just error checking to see if the directory can be removed or if it exists
      If $dirremoveVAR = 0 Then
         MsgBox(48, "Error", "The program was unable to remove the directory or it does not exist. The program will now exit.")
         Exit
      EndIf
     ;If successful runs the 'create' function
      create()
EndFunc
   
;Creates a function called 'create' which recreates the default user directory that was deleted previously   

Func create()
  ;Creates a variable that in turn creates the previously deleted default user directory
   $dircreateVAR = DirCreate("C:\Documents and Settings\Default User")
     ;Error checking if it is successful a MsgBox is displayed saying so
      If $dircreateVAR = 1 Then
         MsgBox(0, "Success", "The directory was successfully created!")
        ;If successful runs the 'copy' function
         copy()
      EndIf
     ;Error checking if unsuccessful a MsgBox is displayed saying so and then exits
      If $dircreateVAR = 0 Then
         MsgBox(48, "Error", "There was an error creating the directory. The program will now exit.")
         Exit
      EndIf
   EndFunc

;Creates a function called 'copy' that copies the files from the location stored in the settings.ini file

Func copy()
  ;Creates a variable that looks for the location to copy the default user profile from 
   $copyINI = IniRead("settings.ini", "dpc", "location", "0")
  ;Creates a variable that copies the files from the location specified in the settings.ini file
   $copyVAR = DirCopy($copyINI, "C:\Documents and Settings\Default User", 1)
     ;Error checking if successful displays a MsgBox saying so
      If $copyVAR = 1 Then
         MsgBox(0, "Success", "The files were successfully copied to the default profile directory.")
         Exit
      EndIf
     ;Error checking if unsuccessful displays a MsgBox saying so
      If $copyVAR = 0 Then
         MsgBox(48, "Error", "The files were not successfully copied. The program will now exit.")
         Exit
      EndIf
     ;Error checking if the location can't be found in the 'settings.ini' file a MsgBox is displayed saying so
      If $copyINI = 0 Then
         MsgBox(48, "Error", "The location to copy too could not be found. The program will now exit.")
         Exit
      EndIf
   EndFunc

Thanks Heaps!!!

:ph34r:

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...