Sign in to follow this  
Followers 0
Docfxit

Func" statement has no matching "EndFunc

6 posts in this topic

I'm getting an error when I run a script.  I can't find a solution.

The error is:

"C:ProgramsAutoIt3IncludeArray.au3" (53) : ==> "Func" statement has no matching "EndFunc".:
Func _ArrayAdd(ByRef $avArray, $vValue)
 

I am including Array.au3 in my script.  If I look at the supplied (Unmodified) file called Array.au3 at line 53 I see:

Func _ArrayAdd(ByRef $avArray, $vValue)
    If Not IsArray($avArray) Then Return SetError(1, 0, -1)
    If UBound($avArray, 0) <> 1 Then Return SetError(2, 0, -1)

    Local $iUBound = UBound($avArray)
    ReDim $avArray[$iUBound + 1]
    $avArray[$iUBound] = $vValue
    Return $iUBound
EndFunc   ;==>_ArrayAdd

This is what my script that is receiving that error looks like:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; Reload script <ctrl>R
;#RequireAdmin
;AutoIt_Debugger_Command:Disable_Debug
_RunCommonCode

Global $iError = 0, $iExtended = 0, $TryThisOnce = 0, $TryThisAgin = 0
Global $tText = DllStructCreate("char Text[4096]")
Global $pText = DllStructGetPtr($tText), $sMessage = "<None>"
While 1 <> 1
    $sDefaultCMD0 = "2"
    $sDefaultCMD1 = "V"
    $sDefaultCMD2 = "00395400000.TIF"

    ; overwrite the default with the cmd line params
    MsgBox(6, "Test", "UBound($CmdLine)+1 = " & UBound($CmdLine) + 1)
    For $i = 0 To UBound($CmdLine) + 1
        Assign("$sDefaultCMD" & $i, $CmdLine[$i])
        _ArrayDisplay($CmdLine)
        MsgBox(6, "Test", "UBound($CmdLine) = " & UBound($CmdLine) + 1)
        MsgBox(6, "Test", "$CmdLine[$i] = " & $CmdLine[$i] & @CRLF & "$i = " & $i)
    Next
    ConsoleWrite("$sDefaultCMD1=" & $sDefaultCMD1 & @CRLF)
    ConsoleWrite("$sDefaultCMD2=" & $sDefaultCMD2 & @CRLF)
WEnd
;AutoIt_Debugger_Command:Enable_Debug
$sTitle = "ScanFiles"
;If $CmdLine[0] Then
;   _ArrayDisplay($CmdLine)
;EndIf
If $CmdLine[0] = 0 Then Exit MsgBox(16, $sTitle, "No parameters passed!")
;  Local Const $FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000
;MsgBox($MB_TOPMOST, 'TestBox', "B4 DriveMapGet")
While $TryThisAgin = 0
    DriveMapGet("L:")
    If @error = 1 Then
        MsgBox($MB_TOPMOST, 'TestBox', "After DriveMapGet " & "@error = " & @error)
        $RemoteShare = "ATU1277"
        DriveMapAdd("L:", "\\" & $RemoteShare & "\SCANS", 0, "atu1277\SCANS", "password"); Local account on remote computer
        $iError = @error
        $iExtended = @extended
        ;       MsgBox($MB_TOPMOST, 'TestBox 1', "After DriveMapAdd " & "$error = " & $iError & @CRLF & "$extended = " & $iExtended & @CRLF & $RemoteShare)
        ;MsgBox(262144 + 64, "Error Mapping Drive 1",  "@iError = " & $iError & @CRLF & "@iExtended = " & $iExtended & @CRLF)
        $TryThisAgin = 0 ; Try to see if the mapped drive is working now

        _CheckError($iError, $iExtended)
        ; Try this once
        While $TryThisOnce = 0
            If IsAdmin() Then
            Else
                MsgBox(64, "Required", " You need administrator rights to map a drive.")
                Exit
            EndIf

            If $iExtended = "53" Or $iError = "5" Then
                $strHost = @SystemDir & "\drivers\etc\hosts"
                $tcpIP = "192.168.2.1"
                $sWhat = "atu1277"
                $hFile = FileOpen($strHost, 1) ; The 1 parameter just appends to the end of the file
                $filewritten = FileWrite($hFile, @LF & $tcpIP & " " & $sWhat)
                If $filewritten = 1 Then
                    MsgBox($MB_TOPMOST, 'TestBox 3', "Host file was written  " & "@error = " & @error & @CRLF & $strHost)
                Else
                    If Not FileSetAttrib($strHost, "-R") Then ; The file is closed automatically here
                        MsgBox($MB_TOPMOST, 'TestBox 3', "After Host file write was read only " & "@error = " & @error & @CRLF & $strHost)
                    EndIf
                    $hFile = FileOpen($strHost, 1) ; The 1 parameter just appends to the end of the file
                    FileWrite($hFile, @LF & $tcpIP & " " & $sWhat)
                EndIf
                FileClose($hFile)
                FileSetAttrib($strHost, "+R")

            EndIf
            If $iExtended = "0" Or $iError = "3" Then ;"The device is already assigned."
                DriveMapDel("L:")
                MsgBox(6, "DriveMap", "MapDrive L: Deleted")
            EndIf
            $TryThisOnce = 1
        WEnd
    Else
        MsgBox($MB_SYSTEMMODAL, "", "Drive L: is mapped to: " & DriveMapGet("L:"))
    EndIf
WEnd ; Try to map the drive again
$Line1 = $CMDLINE[1]
;If $CMDLINE[0] = 2 Then
;   MsgBox($MB_TOPMOST, 'CMDLINE', "Passed Paramater 0 = " & $CMDLINE[0] & @CRLF & "Passed Paramater 1 = " & $CMDLINE[1] & @CRLF & "Passed Paramater 2 = " & $CMDLINE[2])
;Else
;   If $CMDLINE[0] = 1 Then
;       MsgBox($MB_TOPMOST, 'CMDLINE', "Passed Paramater 0 = " & $CMDLINE[0] & @CRLF & "Passed Paramater 1 = " & $CMDLINE[1])
;   EndIf
;EndIf
_CheckIfIrfanViewIsInstalled
; View a document...
If $CMDLINE[1] = "V" Then
    Run($ProgramFiles & "IRFANVIEW\I_VIEW32" & " " & "L:\" & $CMDLINE[2])
Else
    ; Scan a document
    If $CMDLINE[1] = "S" Then
        Run($ProgramFiles & "IRFANVIEW\I_VIEW32" & " /scan /convert=" & "L:\" & $CMDLINE[2])
    Else
        MsgBox($MB_TOPMOST, 'CMDLINE  Error', "Error" & @CRLF & "Passed Paramater 0 = " & $CMDLINE[0] & @CRLF & "Passed Paramater 1 = " & $CMDLINE[1] & @CRLF & "Passed Paramater 2 = " & $CMDLINE[2])

    EndIf
EndIf
Exit

Func _CheckIfIrfanViewIsInstalled()
    If Not FileExists($ProgramFiles & "IrfanView\i_view32.exe") Then
        ; Assign a Local variable the empty string which will contain the files names found.
        Global $sFileName = "", $iResult = 0, $SourceFolder = ""

        _FindFile() ;Find the folder IrfanView is in, And the name of the file

        ;MsgBox(0, "File", "File to run = " & $SourceFolder & $sFileName)
        Run($SourceFolder & $sFileName)
        WinWait("IrfanView Setup", "Create IrfanView sho")
        If Not WinActive("IrfanView Setup", "Create IrfanView sho") Then WinActivate("IrfanView Setup", "Create IrfanView sho")
        WinWaitActive("IrfanView Setup", "Create IrfanView sho")
        Send($ProgramFiles & "\{SHIFTDOWN}i{SHIFTUP}rfanView{SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{DOWN}{SHIFTDOWN}{TAB}{TAB}{SHIFTUP}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{SPACE}{SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{ENTER}")
        WinWait("IrfanView Setup", "What's new in this v")
        If Not WinActive("IrfanView Setup", "What's new in this v") Then WinActivate("IrfanView Setup", "What's new in this v")
        WinWaitActive("IrfanView Setup", "What's new in this v")
        Send("{ENTER}")
        WinWait("IrfanView Setup", "Do you want to assoc")
        If Not WinActive("IrfanView Setup", "Do you want to assoc") Then WinActivate("IrfanView Setup", "Do you want to assoc")
        WinWaitActive("IrfanView Setup", "Do you want to assoc")
        Send("{ALTDOWN}n{ALTUP}")
        If WinExists("IrfanView Setup", "Include Google &Chro") Then
            WinWait("IrfanView Setup", "Include Google &Chro")
            If Not WinActive("IrfanView Setup", "Include Google &Chro") Then WinActivate("IrfanView Setup", "Include Google &Chro")
            WinWaitActive("IrfanView Setup", "Include Google &Chro")
            Send("{SPACE}{ALTDOWN}n{ALTUP}")
        EndIf
        WinWait("IrfanView Setup", "Destination director")
        If Not WinActive("IrfanView Setup", "Destination director") Then WinActivate("IrfanView Setup", "Destination director")
        WinWaitActive("IrfanView Setup", "Destination director")
        Send("{ALTDOWN}n{ALTUP}")
        WinWait("IrfanView Setup", "Open IrfanView &FAQs")
        If Not WinActive("IrfanView Setup", "Open IrfanView &FAQs") Then WinActivate("IrfanView Setup", "Open IrfanView &FAQs")
        WinWaitActive("IrfanView Setup", "Open IrfanView &FAQs")
        Send("{SPACE}{ALTDOWN}d{ALTUP}")
        WinWait("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
        If Not WinActive("IrfanView Frequently Asked Questions - Mozilla Firefox", "") Then WinActivate("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
        WinWaitActive("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
        Send("{SHIFTDOWN}{CTRLDOWN}w{SHIFTUP}{CTRLUP}")
    EndIf
EndFunc   ;==>_CheckIfIrfanViewIsInstalled


Func _FindFile()
    If FileExists("C:\Dnload\IrfanView*.exe") Then
        $SourceFolder = "C:\Dnload\"
    Else
        If FileExists("D:\Dnload\IrfanView*.exe") Then
            $SourceFolder = "D:\Dnload\"
        Else
            If FileExists("D:\Dnload\9xAddons\IrfanView*.exe") Then
                $SourceFolder = "D:\Dnload\9xAddons"
            Else
                If FileExists("C:\Dnload\9xAddons\IrfanView*.exe") Then
                    $SourceFolder = "C:\Dnload\9xAddons"
                Else
                    MsgBox(0, "Find", "IrfanView*.exe not found" & @CRLF & "Please download IrfanView.exe")
                EndIf
            EndIf
        EndIf
    EndIf

    ; Assign a Local variable the search handle of all files in the current directory.
    Local $hSearch = FileFindFirstFile($SourceFolder & "\IrfanView*.exe")
    ; Check if the search was successful, if not display a message and return False.
    If $hSearch = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Error: No files/directories matched the search pattern.")
        Return False
    EndIf

    ;While 1
    $sFileName = FileFindNextFile($hSearch)
    ; If there is no more file matching the search.
    ;       If @error Then ExitLoop

    ; Display the file name.
    ;   $iResult = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), "", "File: " & $sFileName)
    ;       If $iResult <> $IDOK Then ExitLoop ; If the user clicks on the cancel/close button.
    ;WEnd

    ; Close the search handle.
    FileClose($hSearch)
EndFunc   ;==>_FindFile



Func _CheckError($iError, $iExtended = '', $LineCalledFrom = @ScriptLineNumber)
    If Not @Compiled Then
        ;   MsgBox($MB_TOPMOST, 'CheckError', '$iError = ' & $iError & @CRLF & '$iExtended = ' & $iExtended & @CRLF & 'Called from Line = ' & $LineCalledFrom)
    EndIf
    If $iError <> 0 Then
        Switch $iError
            Case 1
                $iExtendedErrorMsg = _WinAPI_GetErrorMessage($iExtended)
                MsgBox(0, "Error Mapping Drive 2", "$error = " & $iError & @CRLF & _
                        "@extended = " & $iExtended & @CRLF & _
                        "Error Message = " & $iExtendedErrorMsg & @CRLF & _
                        "Called from Line = " & $LineCalledFrom)
            Case 2
                MsgBox(16, "ERROR", "Access to the remote share was denied." & @CRLF & $RemoteShare & @CRLF & @CRLF & "Check firewall zones on this PC" & @CRLF & "Check to make sure user profile SCANS password is not disabled" & @CRLF & "Try pinging " & $RemoteShare & @CRLF & 'Called from Line = ' & $LineCalledFrom)
                Exit
            Case 3
                MsgBox(64, "WARNING", "The device is already assigned." & @CRLF & _
                        "Called from Line = " & $LineCalledFrom)
            Case 4
                MsgBox(16, "ERROR", "Invalid device name.")
            Case 5
                MsgBox(16, "ERROR", "Invalid remote share. -" & $RemoteShare & "-")
            Case 6
                MsgBox(16, "ERROR", "Invalid password.")
        EndSwitch
        ;       MsgBox(64, "Test 3", _WinAPI_GetErrorMessage($iExtended))
    EndIf
EndFunc   ;==>_CheckError

Func _OSVersion()
    Local $OS_Version, $servicepack_version
    $OS_Version = StringStripWS(StringRegExpReplace(@OSVersion, "(WIN_)|(Microsoft )|(Windows )|(\(TM\))|( Ultimate)", ""), 8)
    $OS_Version = StringRegExpReplace(StringRegExpReplace($OS_Version, '2008', 'Win7'), 'VISTA', 'Vista')
    If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", 'CurrentBuildNumber') > 7000 Then $OS_Version = 'Win7'
    $servicepack_version = StringReplace(@OSServicePack, "Service Pack ", "SP")
    If @error = -1 Then $servicepack_version = ""

    ConsoleWrite($OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') & @CRLF)
    Return $OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '')
EndFunc   ;==>_OSVersion

Func _RunCommonCode()
    #include <Array.au3>
    #include <WinAPI.au3>
    #include <WinAPIDiag.au3>
    #include <WinAPIConstants.au3>
    AutoItSetOption("TrayIconDebug", 1) ;0-off
    ; Set so that tray displays current line number
    If @OSVersion = 'Win_7' Then
        $ProgramFiles = "C:\Programs\"
    Else
        $ProgramFiles = "C:\Program Files\"
    EndIf
EndFunc   ;==>_RunCommonCode

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Change this;

;If $CMDLINE[0] = 2 Then
;   MsgBox($MB_TOPMOST, 'CMDLINE', "Passed Paramater 0 = " & $CMDLINE[0] & @CRLF & "Passed Paramater 1 = " & $CMDLINE[1] & @CRLF & "Passed Paramater 2 = " & $CMDLINE[2])
;Else
;   If $CMDLINE[0] = 1 Then
;       MsgBox($MB_TOPMOST, 'CMDLINE', "Passed Paramater 0 = " & $CMDLINE[0] & @CRLF & "Passed Paramater 1 = " & $CMDLINE[1])
;   EndIf
;EndIf
_CheckIfIrfanViewIsInstalled

to

;If $CMDLINE[0] = 2 Then
;   MsgBox($MB_TOPMOST, 'CMDLINE', "Passed Paramater 0 = " & $CMDLINE[0] & @CRLF & "Passed Paramater 1 = " & $CMDLINE[1] & @CRLF & "Passed Paramater 2 = " & $CMDLINE[2])
;Else
;   If $CMDLINE[0] = 1 Then
;       MsgBox($MB_TOPMOST, 'CMDLINE', "Passed Paramater 0 = " & $CMDLINE[0] & @CRLF & "Passed Paramater 1 = " & $CMDLINE[1])
;   EndIf
;EndIf
_CheckIfIrfanViewIsInstalled()

line 7 has the same issue.  You are also using functions that are not included, variables that are not defined.

The code is non-functional.

FYI: if you have syntax errors, the parser will not always determine your syntax error.  It will throw false positives.  You probably didn't close a loop, or if statement, somewhere.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Thank you for catching that.

I made the changes.  I still have the same error.

Thanks,

Docfxit

Share this post


Link to post
Share on other sites

Throw the includes up to the top, and run it through scite...continue to correct every error that comes up.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Docfxit,

Remove the multiple #include lines from inside the _RunCommonCode function and add them as a separate block to the top of your script. By placing them inside a function you will always generate errors - as you cannot define functions inside other functions and the include files are mostly functions. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Moving the includes up to the top (out of the function) resolved the error.

I was looking for a way to reduce the number of debug lines I had to go through every time I ran debug.

Thanks,

Docfxit

Share this post


Link to post
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
Sign in to follow this  
Followers 0