Jump to content

Please help with errors


Docfxit
 Share

Recommended Posts

Could someone please help me figure out what is wrong with this script?

Errors I am getting:

C:\Dnload\9xAddons\Autoit V3 Script\QuickBooks transactions.au3(225,68) : WARNING: $SS_SUNKEN: possibly used before declaration.
$Status = GUICtrlCreateLabel("", 30, 120, 200, 20, BitOR($SS_SUNKEN,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Dnload\9xAddons\Autoit V3 Script\QuickBooks transactions.au3(225,80) : WARNING: $SS_CENTER: possibly used before declaration.
$Status = GUICtrlCreateLabel("", 30, 120, 200, 20, BitOR($SS_SUNKEN, $SS_CENTER)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Dnload\9xAddons\Autoit V3 Script\QuickBooks transactions.au3(226,98) : WARNING: $BS_MULTILINE: possibly used before declaration.
$Btn_GET = GUICtrlCreateButton("Highlight Vendor Press to select", 100, 65, 90, 40, $BS_MULTILINE)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Dnload\9xAddons\Autoit V3 Script\QuickBooks transactions.au3(225,68) : ERROR: $SS_SUNKEN: undeclared global variable.
$Status = GUICtrlCreateLabel("", 30, 120, 200, 20, BitOR($SS_SUNKEN,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Dnload\9xAddons\Autoit V3 Script\QuickBooks transactions.au3(28,84) : ERROR: _GUICtrlListSelectedIndex(): undefined function.
            $FileSelected = _GUICtrlListGetText($listbox, _GUICtrlListSelectedIndex($listbox)
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Dnload\9xAddons\Autoit V3 Script\QuickBooks transactions.au3(28,85) : ERROR: _GUICtrlListGetText(): undefined function.
            $FileSelected = _GUICtrlListGetText($listbox, _GUICtrlListSelectedIndex($listbox))
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Dnload\9xAddons\Autoit V3 Script\QuickBooks transactions.au3(237,49) : ERROR: _GUICtrlEditGetSel(): undefined function.
            $a_Sel = _GUICtrlEditGetSel ($myedit)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Dnload\9xAddons\Autoit V3 Script\QuickBooks transactions.au3 - 4 error(s), 3 warning(s)

This is my code:

#include <file.au3>
#include <array.au3>
#include <GUIConstants.au3>
#include <GUIListbox.au3>
#include <GuiEdit.au3>

AutoItSetOption("TrayIconDebug", 1) ;0-off
; Set so that tray displays current line number
HotKeySet("{ESC}", "Set_Exit")

Dim $hQBOffSetEntries, $hQBTrans, $hQBTransOut, $Dates, $sString, $NumberOfLines
Dim $fResult = 1, $msg, $AccountSelected, $listbox, $label

; Select a file from a list of files
;
GUICreate("File List", 220, 370)
GUISetFont(9, 400, -1, "MS Sans Serif")
$listbox = GUICtrlCreateList("", 10, 10, 200, 330)
Get_Files()
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $listbox
            $FileSelected = _GUICtrlListGetText($listbox, _GUICtrlListSelectedIndex($listbox))
            If ($FileSelected == $LB_ERR) Then
                MsgBox(16, "Error", "Unknown error from _GUICtrlListGetText")
            Else
                MsgBox(4096, "Test", "File Selected - " & $FileSelected)
                ExitLoop
            EndIf
    EndSelect
WEnd

Func Get_Files()
    $FileList = _FileListToArray("C:\Program Files\QuickBooks Pro 2004", "*.iif", 1) ; list files to an array.
    If (Not IsArray($FileList)) Or (@error = 1) Then
        MsgBox(262208, "Folder Error", "No Files\Folders Found.   ", 5)
        Return
    EndIf
    GUICtrlSetData($listbox, "") ; set list to empty.
    For $x = 1 To $FileList[0] ; for loop to place the files in the list.
;       GUICtrlSetData($listbox, (StringTrimRight($FileList[$x], 4)) & "|", 1) ; string trim the last 4 characters ( .iif )
        GUICtrlSetData($listbox, $FileList[$x] & "|", 1) ; string trim the last 4 characters ( .iif )
    Next
EndFunc   ;==>Get_Files
Global $QBTrans = "C:\Program Files\QuickBooks 2008\" & $FileSelected
Global $QBTransOut = "C:\Program Files\QuickBooks 2008\TestOut.iif" 
Global $QBOffSetEntries = "C:\Program Files\QuickBooks 2008\OffSettingEntries.txt" 
$sPattern = '([^",]*|"(?:[^"]|"")*")(?:,|\Z)' 
_NFileCountLines ($QBOffSetEntries)
Global $Vendor[$NumberOfLines], $Account[$NumberOfLines]

OpenFiles ()
;   MsgBox(64, "Info", "Number of Dimensions: " & _NumDim($Vendor))
;   Func _NumDim(ByRef $avArray)
;       For $iCC = 64 To 1 Step -1
;           If UBound($avArray, $iCC) Then Return $iCC
;       Next
;       Return SetError(1, 0, 0)
;   EndFunc
ReadOffSetEntries()

While $fResult = 1
    $asFields = 1  ; Used for WriteRecords
    ReadRecord()
WEnd

Set_Exit ()
;AutoIt_Debugger_Command:Disable_Debug
Func ReadOffSetEntries()  ; Load the Vendor and Account arrays
;       MsgBox(4096, "$NumberOfLines", $NumberOfLines)
    For $x = 0 To UBound($Vendor) - 1
        Global $sString = FileReadLine($hQBOffSetEntries)
        If $sString = "" Then ExitLoop
        $asFields = StringRegExp($sString, $sPattern, 3)
;               _ArrayDisplay($asFields, "$asFields")
        $Vendor[$x] = $asFields[0]
;               MsgBox(0, "ReadOffSetEntries", '$sString - ' & $sString &  @LF & "Vendor - " & $Vendor[$x] & @lf & "$x - " & $x & @LF & "NumberOfLines - " & $NumberOfLines)
        $Account[$x] = $asFields[1]
        ;               _ArrayDisplay($Vendor, "Vendor")
    Next
    ;       for $i = 0 to UBound($asFields) - 1
    ;           msgbox(4096, "Array Number           -------",  $i & " - " & $asFields[$i] & @LF & "InputString - " & $sString & @LF & UBound($asFields))
    ;       Next
    ;   msgbox(4096, "Contents 2", "$asFields - " & $asFields & @LF & "@error - " & @error)
    ;   _ArrayDisplay($Vendor, "Vendor")
    ;   _ArrayDisplay($Account, "Accounts")
    FileClose($QBOffSetEntries)
    If Not FileExists($QBOffSetEntries) Then
        MsgBox(0, "Error", "File doesn't exist - " & $QBOffSetEntries)
        Exit
    EndIf
    Global $hQBOffSetEntries = FileOpen($QBOffSetEntries, 1)
    If $hQBOffSetEntries = -1 Then
        MsgBox(0, "Error", "Unable to open - " & $QBOffSetEntries)
        Exit
    EndIf

    Return
EndFunc   ;==>ReadOffSetEntries
;AutoIt_Debugger_Command:Enable_Debug

Func ReadRecord()   ;  Read the transaction records
    While $fResult = 1
        Global $sString = FileReadLine($hQBTrans)
        If @error = -1 Then
            ;End of file reached
            ExitLoop
        EndIf
        $asFields = StringRegExp($sString, $sPattern, 3)
;               _ArrayDisplay($asFields, "Input Fields")
        If $asFields[0] = "TRNS"  Then
            $Found = "No" 
            For $x = 1 To UBound($Vendor) - 1
                If StringInStr($asFields[5], $Vendor[$x]) > 0 Then
                    ;                           MsgBox(0,"","FOUND IT!!!")
                    ;                           MsgBox(0, "Found", '"' & $asFields[5] & '" was not found in the array.' & @LF & "Vendor - " & $Vendor[$x] & @lf & "$x - " & $x & @LF & "NumberOfLines - " & $NumberOfLines)
                    $Found = "Yes" 
                $ExpenseAccount = '"' & $Account[$x] & '"' 
                    ExitLoop
                EndIf
                ;                           MsgBox(0, "Not Found", '"' & $asFields[5] & '" was not found in the array.' & @LF & "Vendor - " & $Vendor[$x] & @lf & "$x - " & $x & @LF & "NumberOfLines - " & $NumberOfLines)
            Next
            If $Found = "No"  Then
                GUICreate("Select an expense account for - ", 350, 250, -1, -1)
                $listbox = GUICtrlCreateList("", 95, 40, 180, 150)
                GUICtrlSetData($listbox, "Car/Truck Expense:Gas|Travel & Entertainment:Meals|Hardware|Software|Postage and Delivery|Office:Supplies|Credit Card  DEBIT Offset|Credit Card  CREDIT Offset|Dues and Subscriptions")
                $label = GUICtrlCreateLabel($asFields[5], 45, 20, 320)
                $label = GUICtrlCreateLabel("Date: " & $asFields[3] & "    Amount: " & $asFields[6], 100, 210, 320)

                GUISetState()
                While 1
                    $msg = GUIGetMsg()
                    Select
                        Case $msg = $GUI_EVENT_CLOSE
                            ExitLoop
                        Case $msg = $listbox                ; 3
                            $AccountSelected = _GUICtrlListGetText($listbox, _GUICtrlListSelectedIndex($listbox))
                            If ($AccountSelected == $LB_ERR) Then
                                MsgBox(16, "Error", "Unknown error from _GUICtrlListGetText")
                            Else
                                ;                               GUICtrlSetData($label, "Item : " & $AccountSelected)
                                $ExpenseAccount = '"' & $AccountSelected & '"' 
                                ExitLoop
                            EndIf
                    EndSelect
                WEnd
            GUIDelete()
            UpdateVendors()
            EndIf
            WriteRecords ($asFields)
            Global $sString = FileReadLine($hQBTrans)
            If @error = -1 Then
                ;End of file reached
                ExitLoop
            EndIf
            $asFields = StringRegExp($sString, $sPattern, 3)
;                   _ArrayDisplay($asFields, "Input Fields")
            If $asFields[0] = "SPL"  Then
                $asFields[4] = $ExpenseAccount 
                ;                                   _ArrayDisplay($asFields, "Input Fields")
                ;                                   WriteRecords($asFields)
            EndIf

            WriteRecords ($asFields)  
            ExitLoop
        EndIf
        ;           MsgBox(4096, "Record", "InputString - " & $sString & @LF & "Result - " &$fResult)
        If $asFields[0] = "!TRNS"  Or $asFields[0] = "!SPL"  Or $asFields[0] = "SPL"  Or $asFields[0] = "!ENDTRNS"  Or $asFields[0] = "ENDTRNS"  Then
            WriteRecords ($asFields)
        EndIf
    WEnd
    ;The pattern works as follows:
    ;   ^[^"]*? - matches anything up to the first double-quote
    ;   (?: - starts a group (the '?:' tells StringregExp not to remember the matching text
    ;   ["] - matches an opening double quote
    ;   [^"]*? - matches anything between the double quotes
    ;   ["] - matches a closing double quote
    ;   [^"]*? - matches any characters up to the next double quote
    ;   )*? - finishes the group, and tells RegExp to look for zero or more of these groups (DQ string followed by other chars)
    ;   ["] - matches an unmatched double quote
    ;   [^"]*?$ - matches remaining characters up to the end of the line
    ;       To Test the pattern:
    ;   $sUnterminatedDQ = '^[^"]*?(?:["][^"]*?["][^"]*?)*?["][^"]*?$'
    ;   $sString = 'no double-quoted string in the line'
    ;   $fResult = StringRegExp($sString, $sUnterminatedDQ, 0)
    ;   if @error or $fResult Then ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $fResult = ' & $fResult & @crlf & '>Error code: ' & @error & ', Extended: ' & @extended & @crlf);### Debug Console
    ;   $sString = 'double-quoted "string" in the line'
    ;   $fResult = StringRegExp($sString, $sUnterminatedDQ, 0)
    ;   if @error or $fResult Then ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $fResult = ' & $fResult & @crlf & '>Error code: ' & @error & ', Extended: ' & @extended & @crlf);### Debug Console
    ;   $sString = '"double-quoted string" at start'
    ;   $fResult = StringRegExp($sString, $sUnterminatedDQ, 0)
    ;   if @error or $fResult Then ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $fResult = ' & $fResult & @crlf & '>Error code: ' & @error & ', Extended: ' & @extended & @crlf);### Debug Console
    ;   $sString = 'double-quoted string "at the end"'
    ;   $fResult = StringRegExp($sString, $sUnterminatedDQ, 0)
    ;   if @error or $fResult Then ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $fResult = ' & $fResult & @crlf & '>Error code: ' & @error & ', Extended: ' & @extended & @crlf);### Debug Console
    ;   $sString = 'multiple "double-quoted" strings "in the" line'
    ;   $fResult = StringRegExp($sString, $sUnterminatedDQ, 0)
    ;   if @error or $fResult Then ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $fResult = ' & $fResult & @crlf & '>Error code: ' & @error & ', Extended: ' & @extended & @crlf);### Debug Console
    ;   $sString = 'unterminated "double-quoted string in the line'
    ;   $fResult = StringRegExp($sString, $sUnterminatedDQ, 0)
    ;   if @error or $fResult Then ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $fResult = ' & $fResult & @crlf & '>Error code: ' & @error & ', Extended: ' & @extended & @crlf);### Debug Console
    ;   All of the stuff up to the "unmatched double quote" is necessary to handle correctly matched double quotes in the line ...
EndFunc   ;==>ReadRecord

Func WriteRecords ($asFields)
    ; write records out
    ;   _ArrayDisplay( $asFields, "_ArrayToString() Test" )
    Dim $sRecordOut = _ArrayToString($asFields, ",", 0, 6)
    ;   MsgBox( 4096, "_ArrayToString() Test", $sRecordOut )

    FileWriteLine($hQBTransOut, $sRecordOut & @CRLF)    
EndFunc   ;==>WriteRecords

Func UpdateVendors()
Dim $myedit, $Status, $msg, $Btn_GET, $a_sel, $NewVendorT
GUICreate("Vendor Name Selection", 302, 140)

$myedit = GUICtrlCreateEdit($asFields[5], 20, 32, 270, 27, $ES_AUTOVSCROLL)
GUICtrlSetLimit($myedit, 1500)
$Status = GUICtrlCreateLabel("", 30, 120, 200, 20, BitOR($SS_SUNKEN, $SS_CENTER))
$Btn_GET = GUICtrlCreateButton("Highlight Vendor Press to select", 100, 65, 90, 40, $BS_MULTILINE)

GUISetState()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Btn_GET                   ; 5
            $a_Sel = _GUICtrlEditGetSel ($myedit)
            If ($a_Sel == $EC_ERR) Then
                GUICtrlSetData($Status, "Error getting sel positions")
            ElseIf (IsArray($a_Sel)) Then
                $NewVendor = StringMid(GUICtrlRead($myedit), $a_Sel[1] + 1, ($a_Sel[2] - $a_Sel[1]) + 1)
                $NewVendorT = StringStripWS($NewVendor, 2)
                GUICtrlSetData($Status, $NewVendorT)
                ReDim $Vendor[UBound($Vendor) + 1]
                ReDim $Account[UBound($Account) + 1]
                $Vendor[Ubound($Vendor) -1] = $NewVendorT
                $Account[Ubound($Account) -1] = $AccountSelected
;               _ArrayDisplay($Vendor, "Vendor")
;               _ArrayDisplay($Account, "$Account")
                $sRecordOut = $NewVendorT & "," & $AccountSelected
                FileWriteLine($hQBOffSetEntries, $sRecordOut & @CRLF)   
           Else
                GUICtrlSetData($Status, "")
            EndIf
    GUIDelete()
    ExitLoop
    EndSelect
WEnd
EndFunc   ;==>UpdateVendors

;AutoIt_Debugger_Command:Disable_Debug
Func OpenFiles ()
    If Not FileExists($QBTrans) Then
        MsgBox(0, "Error", "File doesn't exist - " & $QBTrans)
        Exit
    EndIf
    Global $hQBTrans = FileOpen($QBTrans, 0)
    If $hQBTrans = -1 Then
        MsgBox(0, "Error", "Unable to open - " & $QBTrans)
        Exit
    EndIf
    Global $hQBTransOut = FileOpen($QBTransOut, 2)
    If $hQBTransOut = -1 Then
        MsgBox(0, "Error", "Unable to open - " & $QBTransOut & " file.")
        Exit
    EndIf
    If Not FileExists($QBOffSetEntries) Then
        MsgBox(0, "Error", "File doesn't exist - " & $QBOffSetEntries)
        Exit
    EndIf
    Global $hQBOffSetEntries = FileOpen($QBOffSetEntries, 0)
    If $hQBOffSetEntries = -1 Then
        MsgBox(0, "Error", "Unable to open - " & $QBOffSetEntries)
        Exit
    EndIf
EndFunc   ;==>OpenFiles
;AutoIt_Debugger_Command:Enable_Debug

;AutoIt_Debugger_Command:Disable_Debug
Func _NFileCountLines ($sFile)
    Local $AArray
    Local $Content
    Local $FileSize
    If Not FileExists($sFile) Then
        Return 0
    Else
        $FileSize = FileGetSize($sFile)
        $Content = FileRead($sFile, $FileSize)
        If Not StringInStr($Content, @LF) Then
            Return 1
        Else
            $AArray = StringSplit($Content, @LF)
;               _ArrayDisplay($AArray, "$AArray")
            $NumberOfLines = $AArray[0] 
            Return $NumberOfLines
        EndIf
    EndIf
EndFunc   ;==>_NFileCountLines
;AutoIt_Debugger_Command:Enable_Debug

Func Set_Exit ()
    FileClose($QBTrans)
    FileClose($QBTransOut)
    FileClose($QBOffSetEntries)
    Exit
EndFunc   ;==>Set_Exit

Thank you,

Docfxit

Link to comment
Share on other sites

You get "WARNING: $SS_SUNKEN: possibly used before declaration" these sort of errors when you fail to use the correct includes.

Put these at the top of your script to remove these errors

#include <StaticConstants.au3>
#include <ButtonConstants.au3>

The functions you're using:

_GUICtrlListSelectedIndex()

_GUICtrlListGetText()

_GUICtrlEditGetSel()

...don't even exist in the current version. Are you using an old version? Current stable version is v3.2.12.1.

Check the help file to see which functions you need.

Hint: This may be what you need:

_GUICtrlListBox_GetSelItems

_GUICtrlListBox_GetText

_GUICtrlEdit_GetSel

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
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...