12 Replies Latest reply on Nov 2, 2010 9:10 AM by philmodjunk

    Need help: script to automate barcode scanner

    xtremu

      Title

      Need help: script to automate barcode scanner

      Post

      Hi All,

      I am using FM Pro 11 advanced and I'm preparing the database for the gate entry of the school. I have two tables, the student table that holds data of the students and the history table that holds the time in and time out of the student in the portal which in place at the student table or layout. I have a fieldname Student Number, field that trigger for the barcode which is correspond to the barcode that I printed.

      I used Symbol LS9208 omni directional barcode scanner in the database and I tried it, what I did is to press the Ctl F and place the cursor to the student name field and start scanning and fortunately it works, student informations are displayed in my interface. Please try to figure out that after opening the file, it will automatically perform the task by waiting student ID with student number barcode to scan.

      My problem is how to automate this task and not by using the Ctrl F command and place cursor to the student number field manually, is there any script for this or any relation or additional field to be created before it will works? 

      Thanks in advance.

      xtremu 

        • 1. Re: Need help: script to automate barcode scanner
          philmodjunk

          Almost all barcode scanners can be configured to put text before and after the scanned barcode. If you are using filemaker 10 or 11, you can use OnKeystroke script triggers that check for and respond to these before and after codes to trigger scripts that do what you need. If you set up the scanner to append a tab, return or enter character to the end of the scanned text, you can also use an OnObjectExit to trigger any post scan processing you need to do.

          You'll need to check the documentation that comes with the scanner or maybe the manufacturer's tech support to figure out how to configure your scanner to do this.

          • 2. Re: Need help: script to automate barcode scanner
            RobBishop

            Am I to understand you just need the scanner function to remain "on ready" for the next scan each time? If so wouldn't a loop take care of this for you?

            • 3. Re: Need help: script to automate barcode scanner
              philmodjunk

              scanners almost always are used in "keyboard emulation mode". Thus input from the scanner is processed by your computer just as though you had rapidly typed in the scanned info.

              I've used scanners with just such a loop back in the days before script triggers. I paused the loop with pause/resume script and an enter key character programmed in the scanner as a "postamble" was appended to the end of the scan to continue the paused script--which then processed the scanned data to do what the user needed--in my case to check lending library items in or out of inventory.

              With script triggers, you can make things more responsive as you can just have the right layout up and start scanning. The first script trigger script can put the cursor in the correct field to recieve the scanned data and the second can process the scanned data.

              • 4. Re: Need help: script to automate barcode scanner
                xtremu

                Thank you guys, i already used the Onkeystroke script, please provide us the script that automatically trigger the Student Number field and that ready to accept or scan the barcode. Using New Record/Request script i think is not included?, im not sure anyway it's just because I had already an existing data or record  in my database.

                What i want is to find the record in my existing database automatically using student id barcode and not to add another record. 

                Thanks for the procedures and script in advanced.

                • 5. Re: Need help: script to automate barcode scanner
                  RobBishop

                  Can you explain a bit more what you need to happen?

                  Example: You need it to scan the barcode (student number) and find the students info.

                  Then do what? Display that info? Check them in somewhere and then return to "ready to scan"?

                  Not being a smarty pants, i just think if you offer a little more detailed information about what you need to do exactly someone could better help you. I know for a fact Phil is a great person for that sort of thing, but you need to give a little more specific info if you can please. =)

                  • 6. Re: Need help: script to automate barcode scanner
                    philmodjunk

                    Here's a possible script example modified from a similar setup with a mag strip reader we use (also uses keyboard emulation and can be configured to put characters at the begining and end of the scan):

                    First the reader was configured to put shift-capslock-~ at the beginning and the Enter key character at the end.

                    The First script:
                    If [ Get ( TriggerKeystroke ) = "~"  and
                         Get ( TriggerModifierKeys ) = 3 /* Modifier 3 means shift and capslock are down */ ]
                        #Put cursor in field for scanned data
                        Go to field [ table::gStudentID ] // gStudent ID should be a global field
                        Exit Script [ Result: False ] // False result keeps trigger characters from being entered into field
                    End If

                    Set this as the OnLayoutKeystroke trigger in Layout Setup...

                    2nd script:
                    Enter Find Mode [] // clear pause check box
                    Set Field [ table::StudentID ; table::gStudentID ]
                    Set Error capture [on] //keeps no records found dialog from interrupting script if nothing matches
                    Perform Find []

                    Select gStudentID and select ONObjectExit to trigger this second script.

                    This example will not work unless global storage is specified for gStudentID in Field options and the field must be present on the layout when the scan is performed. The field may be hidden from view, however, by making it very small such as by making it 2 pixels high and 2 pixels wide.

                    • 7. Re: Need help: script to automate barcode scanner
                      Insight

                      Did You ever get this script to work ??

                      I am looking for a similar solution 

                      Got the trigger to work but having some problems with 

                      Exit Script [ Result: False ] // False result keeps trigger characters from being entered into field

                      Is this an error [ Result: False ] ??

                      Also need to jump to a different field after the trigger enter find mode and paste the barcode string and preform find.

                      PhilModJunk says the global storage is specified for gStudentID in Field options - but why would you find a global field as the same content is in all record fields - I need to jump to a redord ID Field and preform the find based on the scanned barcode reference.

                      Any help on this from any of the posters would be great...

                      Thanks in advance.

                      Bobski

                      • 8. Re: Need help: script to automate barcode scanner
                        philmodjunk

                        Exit Script [ Result: False ] is not an error. You don't type in "Result:" as Filemaker adds that after you type in False (no quotes) and click OK to dismiss the dialog.

                        Also need to jump to a different field after the trigger enter find mode and paste the barcode string and preform find.

                        That's exactly what the second script does, but with out any copy/paste step as this is not necessary.

                        PhilModJunk says the global storage is specified for gStudentID in Field options - but why would you find a global field as the same content is in all record fields - I need to jump to a redord ID Field and preform the find based on the scanned barcode reference.

                        Take another look at the second script.

                        Enter Find Mode [] // clear pause check box
                        Set Field [ table::StudentID ; table::gStudentID ]
                        Set Error capture [on] //keeps no records found dialog from interrupting script if nothing matches
                        Perform Find []

                        The scanned bar code text is entered into the global field by the scanner, then the Set Field step in this script copies the contents of this global field to the non global StudentID field so the find can be performed.

                        • 9. Re: Need help: script to automate barcode scanner
                          Insight

                          Excellent Phil...

                          My mistake(s) didn't see the gStudentID (globalStudentID field) makes perfect sense now.

                          Great Work around !

                          Do you know if you can get a DataLogic Barcode scanner to fire 'CMD Alt Shift 4' as a keyboard shortcut to call a custom menu with a script attached.

                          Can't seem to find how to call the "Command key" into the sequence just Alt  & Shift etc. but you can't trigger a custom menu (keyboard shortcut) without the Command Key.

                          Don't think I'll need it now anyway with your script example.

                          Thanks Anyway for your prompt reply and help...

                          • 10. Re: Need help: script to automate barcode scanner
                            philmodjunk

                            Do you know if you can get a DataLogic Barcode scanner to fire 'CMD Alt Shift 4'.

                            I'd contact DataLogic and ask them that question, if you still need that option.

                            • 11. Re: Need help: script to automate barcode scanner
                              Insight

                              Phill

                              Cant seem to get the script to run the second script - does the scan but wont exit the field ( the temp gStudentID field)

                              So the ONObjectExit second part doesnt work.

                              If I click outside the the temp gStudentID field (which is the on exit part) it then works through to the find.

                              I can't get the cursor to exit the temp gStudentID field so as it goes to the ONObjectExit trigger. The cursor is just flashing temp gStudentID field. 

                              Any ideas Phil ?

                              • 12. Re: Need help: script to automate barcode scanner
                                philmodjunk

                                The scanner has to be configured to add a return, enter or tab character to the end of the stream of scanned text in order for that to work. You also have to have the field configured in the Inspector so that whichever character you selected for this is set in behavior to exit the field.

                                You can test your script trigger and field settings by clicking into the field and pressing the same key that you specified for your scanner. If that triggers the script, then the issue lies with how you've configured your scanner.