Jump to content
Sign in to follow this  
ZebrasInBlankets

CSV - If not foud then..

Recommended Posts

#include <File.au3>

HotkeySet("!1", "testdb")
while 1
    sleep(100)
wend

Func testDB()
    $in_filename = "test.csv"
    Dim $lines,$Display, $NumCols
    _FileReadToArray($in_filename, $lines)
    $Columns = StringSplit($lines[1], ",")
    $NumCols=$Columns[0]
    Dim $array[ $lines[0] ][ $Columns[0] ]
    For $i = 1 To $lines[0]
        $Columns = StringSplit($lines[$i], ",")
        If $Columns[0] = 1 Then Continueloop
        For $j = 1 To $Columns[0]
            $array[$i-1][$j-1] = $Columns[$j]
        Next
    Next
    $Rows=$Lines[0]-1
    $num_id = 12345 
    $p = 0
    while 1
        if $array[$p][0] = $num_id then
            if $array[$p][2] = 1 then
                DoIt()              
            else
                Send("{ESC}")
            endif
            exitloop
        else
            $p = $p + 1
            ContinueLoop
        endif
    wend
EndFunc

Func DoIt()
    Sleep(2500)
    Send("{F8}")
EndFunc

OK, what I want to do is: If $numid is not in the csv/array then DoSomethingElse. I tried numerous times with no avail.

Any help is greatly appreciated..

Share this post


Link to post
Share on other sites

I would suggest that you do something with $Rows. If $Rows = $p then you're out of records in the CSV file. Using this logical condition would allow you to end the While/Wend loop and do something else.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...