Jump to content

Func/Endfunc problems...


koresho
 Share

Recommended Posts

Hey, I have a script that has worked for a while, and suddenly it randomly stops working. I made a couple of modifications, but they were nothing to do with the functions... anyway here is the source:

(only changes are removal of proprietary website addresses and personal names from script)

#region Includes
;==Includes================================================
#include <GuiConstants.au3>
#include "RunOptimization.au3"
#include "Update.au3"
#include "Inst - Norton360.au3"
#include "Inst - NortonAV.au3"
#include "Inst - NortonIS.au3"
#include "Inst - SpySweeper.au3"
#include "Inst - LiveOne.au3"
#include "Diag - Analyzer.au3"
#include "Diag - MemTest.au3"
#include "Diag - DFT.au3"
#include "Diag - PCDoctor.au3"
#include "Diag - SeaTools.au3"
#include "Opt - Tweaks.au3"
#include "Opt - Cleanup.au3"
#include "Opt - Defragment.au3"
#include "Opt - KillUAC.au3"
#include "Opt - MSConfig.au3"
#include "Opt - RegistryFix.au3"
#include "Opt - UninstallPrograms.au3"
#include "Fix - WinSockFix.au3"
#include "Removal - NortonRemoval.au3"
#include "Removal - McAfeeRemoval.au3"
#include "Removal - AOLCleaner.au3"
#include "Removal - AdAware.au3"
#include "Removal - Spybot.au3"
#include "Removal - Spydoc.au3"
#include "Removal - TrojanHunter.au3"
#include "Removal - TrendMicro.au3"
#include "Removal - HijackThis.au3"
#include "Removal - Specific.au3"
#include "Other - VZAM.au3"
#include "Advisor.au3"
#include "Screensaver.au3"
#include "Readme.au3"
#include "Options.au3"
#include "Run.au3"
#RequireAdmin
#endregion

#region Startup
;==Check Compilation=======================================
If @Compiled = False Then
    MsgBox(0,"Start","Compile first retard!")
EndIf
;==Program Options=========================================
Global $version = " 0.7c"
Global $copyright = "!0169 2007"
HotKeySet("^+e","_quit")
TraySetClick(16)
TraySetToolTip("Start" & $version)
Opt("TrayMenuMode", 1)
Opt("TrayAutoPause", 0)
Opt("RunErrorsFatal", 0)
Opt("SendKeyDelay",1)
Opt("SendKeyDownDelay",1)
$forums = TrayCreateItem("Support Forums")
$trayoptions = TrayCreateItem("Options")
$trayabout = TrayCreateItem("Readme")
TrayCreateItem("")
$trayexit = TrayCreateItem("Exit")
Global $typerun, $typeexecute = ""
;Install removed. Replaced by InstallShield installer. 
;Activation section removed. Any activation will be taken care of by setup program. 
#endregion

#region Main GUI
;==Main GUI================================================
Global $maingui = ""
$maingui = GUICreate("Start " & $version, 180, 210, -1, -1)
GUICtrlCreateLabel($copyright, 8, 5)
$runop = GUICtrlCreateButton("Run Optimization", 10, 40, 160, 30, $BS_DEFPUSHBUTTON)
$runinsta = GUICtrlCreateButton("Install Software", 10, 70, 160, 30)
$diagnos = GUICtrlCreateButton("Run Diagnostics", 10, 100, 160, 30)
$update = GUICtrlCreateButton("Update Program", 10, 130, 160, 30)
;$readme = GUICtrlCreateButton("View Readme", 10, 175, 160, 30)
$removals = GUICtrlCreateMenu("Removals")
$aolclean = GUICtrlCreateMenuItem("AOL Removal", $removals)
$malwaremenu = GUICtrlCreateMenuItem("Malware Removal", $removals)
$mrt = GUICtrlCreateMenuItem("McAfee Removal", $removals)
$nrt = GUICtrlCreateMenuItem("Norton Removal", $removals)
$run = GUICtrlCreateMenu("Run...")
$addrem = GUICtrlCreateMenuItem("Add/Remove Programs", $run)
$msconfig = GUICtrlCreateMenuItem("MS Configuration", $run)
$admintools = GUICtrlCreateMenuItem("Admin Tools", $run)
$chkdsk = GUICtrlCreateMenuItem("CheckDisk", $run)
$cmd = GUICtrlCreateMenuItem("Command Prompt", $run)
$devman = GUICtrlCreateMenuItem("Device Manager", $run)
$diskman = GUICtrlCreateMenuItem("Disk Manager", $run)
$disp = GUICtrlCreateMenuItem("Desktop Manager", $run)
$driververify = GUICtrlCreateMenuItem("Driver Verifier", $run)
$inetprop = GUICtrlCreateMenuItem("Internet Options", $run)
$network = GUICtrlCreateMenuItem("Network Connections", $run)
$powerconfig = GUICtrlCreateMenuItem("Power Configuration", $run)
$registry = GUICtrlCreateMenuItem("Registry Editor", $run)
$filecheck = GUICtrlCreateMenuItem("System File Check", $run)
$winupdate = GUICtrlCreateMenuItem("Windows Update", $run)
$other = GUICtrlCreateMenu("Other")
$advisor = GUICtrlCreateMenuItem("Install Advisor", $other)
$screensaver = GUICtrlCreateMenuItem("Install Screensaver", $other)
$vzam = GUICtrlCreateMenuItem("Install VZAccess", $other)
$private1 = GUICtrlCreateMenuItem("Go to [removed for privacy purposes]", $other)
$private2 = GUICtrlCreateMenuItem("Go to [removed for privacy purposes]", $other)
$411 = GUICtrlCreateMenuItem("Go to 411", $other)
$wsfix = GUICtrlCreateMenuItem("Winsock Error Fix", $other)
$about = GUICtrlCreateMenuItem("About Start", $other)

;TrayTip("Start", "Choose an action to perform.", 30, 2)
GuiSetState()

While(1)
    $msg = GuiGetMsg()
    If $msg = $runop Then _runopgui()
    If $msg = $runinsta Then _runinstagui()
    If $msg = $diagnos Then _diagnos()
    If $msg = $update Then _update()
    If $msg = $malwaremenu Then _malware()
    If $msg = $about Then _readme()
    If $msg = $screensaver Then _screensaver()
    If $msg = $nrt Then _nortonremoval()
    If $msg = $mrt Then _mcafeeremoval()
    If $msg = $aolclean Then _aolclean()
    If $msg = $advisor Then _advisor()
    If $msg = $wsfix Then _wsfix()
    If $msg = $411 Then 
        $typerun = "http://[website removed for privacy purposes]"
        $typeexecute = "ShellExecute"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $forums Then MsgBox(0, "Start", "Forum area still under construction.")
    If $msg = $vzam Then _vzam()
    If $msg = $private1 Then 
        $typerun = "iexplore.exe https://[website removed for privacy purposes]"
        $typeexecute = "RunCmd"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $private2 Then 
        $typerun = "iexplore.exe https://[website removed for privacy purposes]"
        $typeexecute = "RunCmd"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $addrem Then 
        $typerun = "appwiz.cpl"
        $typeexecute = "RunCmd"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $msconfig Then 
        $typerun = "msconfig"
        $typeexecute = "RunCmd"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $admintools Then 
        $typerun = "control admintools"
        $typeexecute = "RunCmd"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $chkdsk Then 
        $typerun = "chkdsk"
        $typeexecute = "RunCmd"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $cmd Then 
        $typerun = "cmd"
        $typeexecute = "RunCmd"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $devman Then 
        $typerun = "devmgmt.msc"
        $typeexecute = "RunCmd"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $diskman Then 
        $typerun = "diskmgmt.msc"
        $typeexecute = "RunCmd"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $disp Then 
        $typerun = "desk.cpl"
        $typeexecute = "RunCmd"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $driververify Then 
        $typerun = "verifier"
        $typeexecute = "RunCmd"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $inetprop Then 
        $typerun = "inetcpl.cpl"
        $typeexecute = "RunCmd"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $network Then 
        $typerun = "control netconnections"
        $typeexecute = "RunCmd"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $powerconfig Then 
        $typerun = "powercfg.cpl"
        $typeexecute = "RunCmd"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $registry Then 
        $typerun = "regedit"
        $typeexecute = "RunCmd"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $filecheck Then 
        $typerun = "sfc /scannow"
        $typeexecute = "RunCmd"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $winupdate Then 
        $typerun = "wupdmgr"
        $typeexecute = "RunCmd"
        _run($typerun, $typeexecute)
    EndIf
    If $msg = $GUI_EVENT_CLOSE Then Exit
    $traymsg = TrayGetMsg()
    If $traymsg = $trayoptions Then _options()
    If $traymsg = $trayabout Then _readme()
    If $traymsg = $trayexit Then Exit
WEnd
#endregion

#region Secondary GUIs
;==Optimization GUI========================================
Func _runopgui()
    GUISetState(@SW_HIDE, $maingui)
    global $opgui, $uackill, $msconfig, $tweaks, $programs, $regfix = ""
    $opgui = GUICreate("Optimization", 190, 230, -1, -1)
    GUICtrlCreateLabel($copyright, 10, 5)
    GUICtrlCreateLabel("Choose actions to perform:", 10, 20)
    $uackill = GUICtrlCreateCheckbox(" Silence UAC (Vista Only!)",10,40)
    $msconfig = GUICtrlCreateCheckbox(" Clean Startup",10,60)
    $tweaks = GUICtrlCreateCheckbox(" Run RegTweaks",10,80)
    $programs = GUICtrlCreateCheckbox(" Uninstall Additional &Programs",10,100)
    $cleanup = GUICtrlCreateCheckbox(" Remove Temp Files",10,120)
    $regfix = GUICtrlCreateCheckbox(" Fix Registry using MS RegClean",10,140)
    $defrag = GUICtrlCreateCheckbox(" Defragment Hard Disks",10,160)
    $back = GUICtrlCreateButton("Back",5,190,88,30)
    $execute = GUICtrlCreateButton("Go",98,190,87, 30, $BS_DEFPUSHBUTTON)
    GuiSetState()
    
        While(1)
            $msg = GuiGetMsg()
            If $msg = $execute Then
                GUISetState(@SW_HIDE,$opgui)
                _runop($uackill, $msconfig, $tweaks, $cleanup, $programs, $regfix, $defrag)
                GUISetState(@SW_SHOW,$opgui)
            EndIf
            If $msg = $back Then
                GUISetState(@SW_HIDE,$opgui)
                GUISetState(@SW_SHOW,$maingui)
                $traymsg = TrayGetMsg()
                If $traymsg = $trayoptions Then _options()
                If $traymsg = $trayabout Then _readme()
                If $traymsg = $trayexit Then Exit
                ExitLoop
            EndIf
            If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        WEnd
EndFunc
    
;==Install GUI=========================================
Func _runinstagui()
    GUISetState(@SW_HIDE, $maingui)
    Global $instagui = ""
    $instagui = GUICreate("Install", 180, 220, -1, -1)
    GUICtrlCreateLabel("Copyright 2007", 10, 5)
    $instn360 = GUICtrlCreateButton("Install &Norton 360", 10, 30, 160, 30, $BS_DEFPUSHBUTTON)
    $instnis = GUICtrlCreateButton("Install Norton &Internet Security", 10, 60, 160, 30)
    $instnav = GUICtrlCreateButton("Install Norton &AntiVirus", 10, 90, 160, 30)
    $instlive = GUICtrlCreateButton("Install Live &OneCare", 10, 120, 160, 30)
    $instspy = GUICtrlCreateButton("Install &SpySweeper", 10, 150, 160, 30)
    $back = GUICtrlCreateButton("Back",10,180,160,30)
    
    GuiSetState ()
;traytip carried over from previous function
    While(1)
        $msg = GuiGetMsg()
        If $msg = $instn360 Then _instn360()
        If $msg = $instnis Then _instnis()
        If $msg = $instnav Then _instnav()
        If $msg = $instlive Then _instlive()
        If $msg = $instspy Then _instspy()
        If $msg = $back Then
            GUISetState(@SW_HIDE)
            GUISetState(@SW_SHOW,$maingui)
            ExitLoop
        EndIf
        $traymsg = TrayGetMsg()
        If $traymsg = $trayoptions Then _options()
        If $traymsg = $trayabout Then _readme()
        If $traymsg = $trayexit Then Exit
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc
;==Diagnostic GUI==========================================
Func _diagnos()
    GUISetState(@SW_HIDE, $maingui)
    Global $diaggui = ""
    $diaggui = GUICreate("Diagnostic", 180, 220, -1, -1)
    GUICtrlCreateLabel("Copyright 2007", 10, 5)
    $sysanalyze = GUICtrlCreateButton("Run System Analyzer 5", 10, 30, 160, 30, $BS_DEFPUSHBUTTON)
    $pcdoc = GUICtrlCreateButton("Run PC Checkup", 10, 60, 160, 30)
    $msmem = GUICtrlCreateButton("Burn MS MemTest", 10, 90, 160, 30)
    $dft = GUICtrlCreateButton("Burn DFT HDD Test", 10, 120, 160, 30)
    $seatool = GUICtrlCreateButton("Burn SeaTools HDD Test", 10, 150, 160, 30)
    $back = GUICtrlCreateButton("Back",10,180,160,30)
    
    GuiSetState ()
    While(1)
        $msg = GuiGetMsg()
        If $msg = $sysanalyze Then _analyzer()
        If $msg = $dft Then _dftrun()
        If $msg = $msmem Then _memtest()
        If $msg = $pcdoc Then _pcdocrun()
        If $msg = $seatool Then _seatool()
        If $msg = $back Then
            GUISetState(@SW_HIDE)
            GUISetState(@SW_SHOW,$maingui)
            ExitLoop
        EndIf
        $traymsg = TrayGetMsg()
        If $traymsg = $trayoptions Then _options()
        If $traymsg = $trayabout Then _readme()
        If $traymsg = $trayexit Then Exit
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc
;==Malware Removal GUI======================================
Func _malware()
    GUISetState(@SW_HIDE, $maingui)
    Global $malwaregui = ""
    $malwaregui = GUICreate("MalClean", 180, 250, -1, -1)
    GUICtrlCreateLabel("Copyright 2007", 10, 5)
    $spybot = GUICtrlCreateButton("Run Spybot S&D", 10, 30, 160, 30, $BS_DEFPUSHBUTTON)
    $adaware = GUICtrlCreateButton("Run Ad-Aware", 10, 60, 160, 30,)
    $hijack = GUICtrlCreateButton("Run HiJack This", 10, 90, 160, 30,)
    $spydoc = GUICtrlCreateButton("Install Spyware Doc", 10, 120, 160, 30,)
    $trojhunt = GUICtrlCreateButton("Install Trojan Hunter", 10, 150, 160, 30,)
    $trendmic = GUICtrlCreateButton("Install Trend Micro AV", 10, 180, 160, 30,)
    $back = GUICtrlCreateButton("Back", 10, 210, 160, 30,)
    
    GuiSetState ()
    While(1)
        $msg = GuiGetMsg()
        If $msg = $spybot Then _spybot()
        If $msg = $adaware Then _adaware()
        If $msg = $trojhunt Then _trojanhunter()
        If $msg = $hijack Then _hijack()
        If $msg = $spydoc Then _spydoc()
        If $msg = $trendmic Then _trendmicro()
        If $msg = $back Then
            GUISetState(@SW_HIDE)
            GUISetState(@SW_SHOW,$maingui)
            ExitLoop
        EndIf
        $traymsg = TrayGetMsg()
        If $traymsg = $trayoptions Then _options()
        If $traymsg = $trayabout Then _readme()
        If $traymsg = $trayexit Then Exit
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc
    
#endregion

#region Quit
Func _quit()
    Exit
EndFunc
#endregion

So, tell me what is wrong? I tried to compile this today (it is a small update) and SciTE complains:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\User\Desktop\Scripts\Start\Start.au3"  
C:\Documents and Settings\User\Desktop\Scripts\Start\Start.au3 (234) : ==> "Func" statement has no matching "EndFunc".: 
Func _runopgui() 
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????\
>Exit code: 1   Time: 0.329

I dont know what the deal is, any help would be appreciated. Oh, and is that the correct way to use a copyright symbol? I couldnt find anything to do with it in the Help files. Thanks a lot!

Edited by koresho
Link to comment
Share on other sites

No way to tell with all the includes you have... and i dont

there are errors here

$adaware = GUICtrlCreateButton("Run Ad-Aware", 10, 60, 160, 30,)
    $hijack = GUICtrlCreateButton("Run HiJack This", 10, 90, 160, 30,)
    $spydoc = GUICtrlCreateButton("Install Spyware Doc", 10, 120, 160, 30,)
    $trojhunt = GUICtrlCreateButton("Install Trojan Hunter", 10, 150, 160, 30,)
    $trendmic = GUICtrlCreateButton("Install Trend Micro AV", 10, 180, 160, 30,)
    $back = GUICtrlCreateButton("Back", 10, 210, 160, 30,)

they all have a comma at the end

8)

NEWHeader1.png

Link to comment
Share on other sites

Thanks for picking that comma error out...

as for the includes, they wouldnt matter would they? it's the actual _runopgui() function that is failing... and by the way, if I comment out that function... the next one pulls up the same exact error. I am wondering if it is an error in the SciTE compiler...?

Update: Tried with Aut2EXE compiler, same error so above comment can't be valid. All I am asking is, it says there is no "EndFunc" and clearly there is.

Edited by koresho
Link to comment
Share on other sites

  • Moderators

Thanks for picking that comma error out...

as for the includes, they wouldnt matter would they? it's the actual _runopgui() function that is failing... and by the way, if I comment out that function... the next one pulls up the same exact error. I am wondering if it is an error in the SciTE compiler...?

Update: Tried with Aut2EXE compiler, same error so above comment can't be valid. All I am asking is, it says there is no "EndFunc" and clearly there is.

Yes it makes all the difference, considering the function you are saying is failing is calling functions inside those includes.

One thing to look at, is that it isn't always the "exact" error as reported. A lot of times, you'll find that you didn't close an If with an EndIf or a While with a WEnd, or a For with a Next etc... that is causing that error.

Edit:

Also, run Tidy (Under tools in SciTe) on it, it should mark where it is seeing the error at.

Edited 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

Yes it makes all the difference, considering the function you are saying is failing is calling functions inside those includes.

One thing to look at, is that it isn't always the "exact" error as reported. A lot of times, you'll find that you didn't close an If with an EndIf or a While with a WEnd, or a For with a Next etc... that is causing that error.

Edit:

Also, run Tidy (Under tools in SciTe) on it, it should mark where it is seeing the error at.

I ran Tidy on every include I have, along with the main script, and recompiled with the same result. Tidy did not show up any errors in comments line like I understood that it does if it finds a problem... any other ideas? I also checked about other errors... all the code *seems* to be perfect. All Whiles are closed with WEnds, I dont have any For loops, and all Funcs are closed with EndFuncs. Same with If---Endif. Like I said too, Tidy reports no errors.

Link to comment
Share on other sites

  • Moderators

I ran Tidy on every include I have, along with the main script, and recompiled with the same result. Tidy did not show up any errors in comments line like I understood that it does if it finds a problem... any other ideas? I also checked about other errors... all the code *seems* to be perfect. All Whiles are closed with WEnds, I dont have any For loops, and all Funcs are closed with EndFuncs. Same with If---Endif. Like I said too, Tidy reports no errors.

Not without seeing the other code, it's pretty much a moot thread request without 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

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...