MePHiTiC Posted September 3, 2008 Share Posted September 3, 2008 (edited) 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? expandcollapse popup;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 September 3, 2008 by MePHiTiC Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted September 3, 2008 Share Posted September 3, 2008 (edited) Use ContinueLoop Edited September 3, 2008 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
MePHiTiC Posted September 3, 2008 Author Share Posted September 3, 2008 Use ContinueLoopAhhh Can't believe I missed that! Thanks for the help!MePH Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now