Jump to content
Sign in to follow this  
MePHiTiC

Not sure how to return to While statement

Recommended Posts

MePHiTiC

I've got this below snippet of a script which saves data from a swiped card to a csv file. Today I wanted to add a check to see if the card has already been swiped. It's working for the most part except when a duplicate swipe is seen, I get the msgbox saying "Text was found in file at line #:", but then the script goes ahead and writes the swipe to the csv. I'd like for it to display the msgbox then just return to the while statement waiting for the next swipe, not writing any duplicate data. Any suggestions how I work this out?

;Waits for swipe data from card reader
;---------------------------------------
While 1
    $String = _CommGetLine (@CR, 0, 0)
    If StringRegExp($String, '\%(.*?)\^\d{10}\^1\^.') Then
        $Pattern1 = '\d{10}';Returns ten digit card number
        $Pattern2 = '\%(.*?)\^';Returns first name
        $SwipeResults1 = StringRegExp($String, $Pattern1, 3)
        $SwipeResults2 = StringRegExp($String, $Pattern2, 3)
            
; ----- Start --- Added 09/02/08 as test for dup swipe -----
        $FTIF = _FindTextInFile($OpenCardFile, $SwipeResults1[0])
        If @error Then
            MsgBox(0, "Error!", "Error Code: " & @error)
        ElseIf Not $FTIF Then
        ;MsgBox(0, "No Match", "Text was not found in file")
        Else
            MsgBox(0, "Match", "Text was found in file at line #: " & $FTIF)
        EndIf
; ----- End --- Added 09/02/08 as test for dup swipe -----
        
        FileOpen($OpenCardFile, 1)
        FileWriteLine($OpenCardFile, $SwipeResults1[0] & "," & $SwipeResults2[0] & "," & @MON & "/" & @MDAY & "/" & @YEAR & "," & @HOUR & ":" & @MIN & ":" & @SEC)
        Sleep(1000);1 Sec pause to finish writing file
        FileClose($OpenCardFile);Closes csv file in order to save swipes
        
        SplashTextOn("Company Name", $SwipeResults2[0] & "'s info saved!", 500, 100, -1, 425, 4, "Lucida Console", 20, 800)
        Sleep(1000);Display mesage for 1 seconds
        SplashOff() 
    Else
        MsgBox(16, "An error has occurred!", "Please swipe your patron card again.", 10)
        FileWriteLine($OpenCardFile, "NULL," & "ERROR READING CARD," & @MON & "/" & @MDAY & "/" & @YEAR & "," & @HOUR & ":" & @MIN & ":" & @SEC)
        Sleep(1000);1 Sec pause to finish writing file
        FileClose($OpenCardFile)
    EndIf
WEnd
;---------------------------------------

Thanks!

MePH

Edited by MePHiTiC

Share this post


Link to post
Share on other sites
MePHiTiC

Use ContinueLoop

Ahhh Can't believe I missed that! Thanks for the help!

MePH

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.