Angus McKinnon Posted October 26, 2014 Posted October 26, 2014 I'm working on an inventory database at the moment. It's relatively straightforward but I've hit a bit of a snag with one feature. What we want is for a user to be able to do a quick "stock check" process by zapping barcodes with a reader. Ideally I want this to be possible without returning to the computer - at the moment we have a USB reader with a long lead but will add wireless readers once the solution is up and running. When the reader sees a barcode, all it does is enter the four-digit serial number, as if it has been keyed into a keyboard at speed. I'd like each "blip" to create a new record - each record documents an occurrence of the object being spotted by someone. There is an auto-entered timestamp, and the record links to the main item record with the serial number as the key field. So far so good, but the problem is getting the record creation happening without any user intervention other than the barcode reader. So far I've tried setting up a looping script, but it doesn't allow input whilst the script is running. I've also tried using a script trigger on the serial number field, but it activates as soon as the first digit is received, rather than waiting for the entire string. My next plan was to have the script pause for half a second before continuing, but what it does is accepts the first keystroke, but pauses immediately. During the pause other keystrokes are accepted, and when the script resumes it appends the first keystroke to the end of the string. So if I zap label number 1234, what is actually recorded is 2341. I suppose it wouldn't be impossible to write a calculation to correct this, but it smells like the sort of bodge that will cause problems further down the line. Can anyone suggest a more elegant way of achieving this?
comment Posted October 27, 2014 Posted October 27, 2014 Which character does you scanner output to indicate the end of a scan?
Angus McKinnon Posted October 27, 2014 Author Posted October 27, 2014 It doesn't output anything other than the number itself. (Unless there's some hidden character that doesn't appear in the field) (I'm a bit of a novice when it comes to barcodes)
IdealData Posted October 27, 2014 Posted October 27, 2014 Last I did some barcodes there was a pre-amble and post-amble character. Often they are invisible. Check the docs for the scanner
comment Posted October 27, 2014 Posted October 27, 2014 It doesn't output anything other than the number itself. That's highly unlikely. Easy to test, though: place the cursor in a field and scan the same barcode, say "1234" twice. Then find out the value of: Length ( TargetField ) If it comes out as 8, you will need to program your scanner to output something at the end - preferably a tab or a return. Otherwise you''ll be only able to scan barcodes of fixed length, if you want your scenario to work. Or devise some horrible hack using a pause, which you rightly want to avoid.
IdealData Posted October 27, 2014 Posted October 27, 2014 Why not create the record first and then scan? You can script the new record even in a loop.
comment Posted October 27, 2014 Posted October 27, 2014 Why not create the record first and then scan? You can script the new record even in a loop. Assuming you have paused the script to enable the user to perform a scan - how will you resume?
Angus McKinnon Posted October 27, 2014 Author Posted October 27, 2014 The barcode reader gun is a Metrologic MS1690. I've not installed any drivers or suchlike, the Mac just recognises it as if it's a keyboard. I'll look into it in more detail when I can get back to the machine.
Angus McKinnon Posted November 1, 2014 Author Posted November 1, 2014 We have found a solution. Comment's mention of the length calculation set me on the right track. It turns out that the barcode reader is literally only giving the digits on the number, 1234 gives a length of 4. No hidden characters or other trickery as far as I can see. However, what we've done is the script that is triggered from the barcode entry field has an "if" statement. It does nothing unless the string is 4 characters long, only then does it create the new record etc. The one obvious drawback with this approach is that once we get beyond 9999 we're in trouble, but at that point I'll need a new run of labels printed, so I'll get the barcodes saying "A10000" rather than just the digits, and modify the "if" statement to suit. Hopefully this is helpful, and thanks to all who responded for helping us get the ball rolling.
comment Posted November 1, 2014 Posted November 1, 2014 This is not a good solution. Read your scanner's documentation to find out how to output a tab or a return at the end of a scan.
Angus McKinnon Posted November 1, 2014 Author Posted November 1, 2014 This is not a good solution. What are the disadvantages of this approach? (I'm curious) Read your scanner's documentation to find out how to output a tab or a return at the end of a scan. From a quick skim of the documentation, it looks like we should be able to do that without too much trouble. I suppose then I could use a script trigger on field exit, rather than on keystrokes?
comment Posted November 1, 2014 Posted November 1, 2014 What are the disadvantages of this approach? It's unnecessarily limiting - you may want to use 5-digit codes (or any other length) even before running out of 4-digit ones. It's also wasting CPU cycles, running the script three times shooting a blank for every "live" one. I suppose then I could use a script trigger on field exit Yes. Or, if you manage to get it to output Enter (#13), it can simply resume a paused script.
Angus McKinnon Posted November 3, 2014 Author Posted November 3, 2014 I can appreciate the inelegance of the looping approach, but are processor cycles really an issue with modern machines? I'd imagine that something this simple will barely idle the processor.
LaRetta Posted November 3, 2014 Posted November 3, 2014 I can appreciate the inelegance of the looping approach, but are processor cycles really an issue with modern machines? I'd imagine that something this simple will barely idle the processor.  You are considering the issue isolated but that is not reality.  Take 50 users all running a script across a WAN simultaneously (all demanding use from FMS) and suddenly a VERY SMALL issue is no longer small.  That is why EVERY nanosecond is critically important.  This is an ugly diagram but it holds true (attached) 1
comment Posted November 3, 2014 Posted November 3, 2014 There's also the electricity bill and global warming to consider. Also, tomorrow you'll want to run the same script in iOS, and suddenly the processor is not what you're used to. It's just good practice to make your solution as lean as possible. 1
MaxB. Posted November 3, 2014 Posted November 3, 2014 Assuming you have paused the script to enable the user to perform a scan - how will you resume? get it to output Enter (#13), it can simply resume a paused script. I have made a solution that does this for a register program. Script loop does all setup then pauses, the Enter at the end of the scan unpauses and the loop continues. In this case just do something like: Loop New Record Go to Field [select/Perform; line_items::barcode] Pause/Resume Script [indefinitely] End Loop The scanner NEEDS to append the Enter for this to work though. Also Enter =/= Carrage Return.
fm_toxy Posted December 5, 2014 Posted December 5, 2014 Hi Angus, Checking on serialio.com for your scanner, I found that it is compatible with SerialMagic Pro for the Mac which I use to handle my Intermec SF51s - turning them into a bluetooth keyboard wedge for barcode reading into Filemaker 11, 12, 13 on a pc or mac.. You do have to switch on a post-amble character for your scans, looking at my preferences, I have set a LF character, which I then trap in a triggerscript linked to the barcode entry field to process, but your post-amble character set may be different. Then you don't have to pause any script, since the scanner effects(?) a line feed - which starts the triggerscript. Which involves minimal clock cycles... The barcodes can be of any length and of any agreed standard. My Inventory system now happily digests EAN-128, UPC, JPN barcodes and Seareach Alphanumeric AssetTags. HTH
Recommended Posts
This topic is 3640 days old. Please don't post here. Open a new topic instead.
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