Jump to content

Can somebody figure this out?


Recommended Posts

Hello,

I have created the following script and attached the excel file I am working off of.

The issue is that I can not get a match on array3, even though there clearly is one.

Can somebody please let me know what I am doing wrong here?

#include <GuiConstantsEx.au3>
#include <Excel.au3>
#include <Array.au3>
#include <File.au3>

; GUI
GuiCreate("TEST THIS OUT", 200, 200)
Main ()
Func Main ()
    
$B1 = GUICtrlCreateButton ("IMPORT EXCEL", 10, 20, 100, 20)
$B2 = GUICtrlCreateButton ("REPORT ARRAY", 10, 100, 100, 20)

GUISetState ()

While 1
    $msg = GUIGetMsg()
Select
    case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    case $msg = $B1
            $var = FileSaveDialog("Choose a file.",@ScriptDir&"", "Excel (*.csv)|ALL (*.*)")
            $oExcel = _ExcelBookOpen($var, 0)
            $array1 = _ExcelReadArray($oExcel, 1, 1, 5, 1) 
            $array2 = _ExcelReadArray($oExcel, 1, 2, 5, 1)
            $array3 = _ExcelReadArray($oExcel, 1, 3, 5, 1) 
            $TXTINPUT = (@MyDocumentsDir &'\INPUT01.txt')
            
    case $msg = $B2
            For $n = 0 to UBound($array3) - 1 
            Global $Z = "Z"
                If StringInStr($array3[$n], $Z) Then
                    If (1 + $n) == Int($array1[$n]) Then
                        FileWrite ($TXTINPUT, "Item [" & $n & "] is a match: " & $array1[$n] & @CRLF)
                    Else
                        FileWrite ($TXTINPUT, "Item [" & $n & "] is NOT a match: " & $array1[$n] & @CRLF)
                    EndIf
                EndIf
            Next
EndSelect
WEnd
EndFunc

post-21557-12612707139227_thumb.jpg

Link to comment
Share on other sites

Sorry for the n00b question, but I believe I figured it out.

Here is the answer

While 1
    $msg = GUIGetMsg()
Select
    case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    case $msg = $B1
            $var = FileSaveDialog("Choose a file.",@ScriptDir&"", "Excel (*.csv)|ALL (*.*)")
            $oExcel = _ExcelBookOpen($var, 0)
            $array1 = _ExcelReadArray($oExcel, 1, 1, 5, 1) 
            $array2 = _ExcelReadArray($oExcel, 1, 2, 5, 1)
            $array3 = _ExcelReadArray($oExcel, 1, 3, 5, 1) 
            $TXTINPUT = (@MyDocumentsDir &'\INPUT01.txt')
            
    case $msg = $B2
            For $n = 0 to UBound($array3) - 1 
            Global $Z = "Z"
                If StringInStr($array3[$n], $Z) Then
                    $i = _ArraySearch($array2, (1 + $n), 0, 0, 0, 1)
                        If $i >= 3 Then
                        FileWrite ($TXTINPUT, "Item [" & $i & "] is a match: " & $array1[$i] & @CRLF)
                    Else
                        FileWrite ($TXTINPUT, "Item [" & $i & "] is NOT a match: " & $array1[$n] & @CRLF)
                    EndIf
                EndIf
            Next
EndSelect
WEnd
EndFunc
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...