Skip to content

Commit

Permalink
Fix for data scanner
Browse files Browse the repository at this point in the history
Keep leading or tailing whitespace from validating the input
  • Loading branch information
mikejed authored Feb 24, 2024
1 parent 0c85fc9 commit e7a20e3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions 2. Collect/DataScanner.au3
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=../favicon.ico
#AutoIt3Wrapper_Res_ProductName=CocoNuts Data Scanner
#AutoIt3Wrapper_Res_ProductVersion=2.1
#AutoIt3Wrapper_Res_ProductVersion=2.2
#AutoIt3Wrapper_Res_LegalCopyright=2024 by Michael Garrison
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Expand Down Expand Up @@ -110,13 +110,13 @@ While 1
ContinueLoop
EndIf

If StringLen(GUICtrlRead($hNewDataInput)) < 2 Or StringLeft(GuiCtrlRead($hNewDataInput),1) <> '{' Or StringRight(GuiCtrlRead($hNewDataInput),1) <> '}' Then
If StringLen(GUICtrlRead($hNewDataInput)) < 2 Or StringStripWS(StringLeft(GuiCtrlRead($hNewDataInput),1),3) <> '{' Or StringStripWS(StringRight(GuiCtrlRead($hNewDataInput),1),3) <> '}' Then
MsgBox(16, "Error", "Make sure you've scanned information into the text field 😅")
ContinueLoop
EndIf

; Data entered - now digest the data and add it to the file. Extra data (not indicated by custom column file) is ignored.
$s_Input = Json_Decode(StringStripCR(GUICtrlRead($hNewDataInput)))
$s_Input = Json_Decode(StringStripWS(GUICtrlRead($hNewDataInput),3))

If UBound(Json_ObjGetKeys($s_Input)) - 3 <> UBound($aColList) Then
MsgBox(16, "Error", "The data doesn't seem to be formatted correctly. Maybe try scanning again?")
Expand Down

0 comments on commit e7a20e3

Please sign in to comment.