Parsing Barcode

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AbusedSysAdmin
Posts: 1
Joined: 23 Jul 2017, 17:19

Parsing Barcode

23 Jul 2017, 17:43

I'm trying to have a script fire only if it's reading from a barcode scanner (the script is mostly from code someone posted using timing to distinguish this) and if it meets certain criteria, break the barcode into two chunks and send them separately otherwise just send the whole thing. An example of data I'd like to split is "6000001000591", the last digit is a check digit and ignored. The first part (6000001) is a random number to key off of (6) and a four digit item prepended with zeros padding it. The second part (00059) is a weight with two decimals, so in this case 0.59 lbs. I'm feeding them to a point of sale system that requires me to split things up like this. I'm having a hard time getting an "else" section to work. I can make the scanner send a CR after the scan which might be a way to end the loop for the "else" part (somehow), but if I have a CR being sent on the end, my output from this always starts with that CR (which doesn't work for my situation). Help? I'm sure there's also a better way to split up the string with RegEx...

Loop 10
Hotkey, % "$" A_Index-1, BarCodeHandler, on
BarCodeHandler:
Scan .= SubStr(A_ThisHotkey, 0)
If Strlen(Scan) = 13 && SubStr(Scan,1,3) = 600 && A_TimeSincePriorHotkey < 60
SetTimer, ParseBarcode, -60
If (A_TimeSincePriorHotkey > 100)
Scan := SubStr(A_ThisHotkey, 0)
return
ParseBarcode:
If Scan
Item := SubStr(Scan,4,4)
Weight := SubStr(Scan,8,3) "." SubStr(Scan,11,2)
send %Item%
send {Enter}
Send %Weight%
send {Enter}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], niCode, Rohwedder and 126 guests