Any scanner I've worked with comes with the ability to configure it so you can have text added to the beginning of the stream of scanned text.
You can then use an On Keystroke script trigger specified for the layout to perform a script that checks for the key or key combination that you've set as the "pre-amble" to your stream of scanned text. If it detects this text, use go to field or go to object to place the cursor in the field so that the rest of the scanned text is entered into the field. I use a single key pre-amble with one or more modifier keys and then use Exit Script [false] to keep this text from being entered into a field in the database.
You'll need to consult the technical info that comes with the scanner to figure out how to program it to include such text.
It is a basic symbol scanner with keyboard emulation, so right now I have it reading the first 4 characters of the scanned entry to determine what layout, field, and script to go to next. However, using that On Keystroke trigger fires the next step after the first character and a timer just isn't the trick.
Any scanner I've worked with uses keyboard emulation and can be configured to add text to the beginning and end of the scanned text. That's something of an industry standard approach so software can be synched with the scanner. Have you checked the technical info and/or tech support for this scanner to see if that's possible?
We use this general script outline with one of our scanners:
If [ Get ( TriggerKeystroke ) = "~" and
Get ( TriggerModifierKeys ) = 3 /* Modifier 3 means shift and capslock are down */ ]
Go To Field [YourTable::YourTextField]
Exit Script [ Result: False ]
Note that this script trigger ignores all keystrokes except a specific key and then only if both caps lock and shift are also depressed. It's sole job is to put the cursor in a text field so that the rest of the scanned text can be captured in that text field. We then use an On ObjectExit trigger to process the scanned text. This is where I'd be doing things like using the first 4 characters to identify what layout to switch to. I could also have used Install On Timer in this script as a way to trigger the follow on script to process the scanned data.
Ok but I need it to loop, I need the cursor to sit in the box and read a 4 character entry when it is scanned in. Then depending on which 4 character entry is scanned in it chooses what to do next. So FCN1 is scanned in then perform script script1here, if FCN2 perform script2here. otherwise just keep sitting in that field and see what the scanner enters.
Why would that require a loop?
Keep in mind that there's a follow on script performed by either a script trigger or timer to process the scanned data. Each time you scan something, it starts the process all over again.
True, good point...
Ok, works great in my sample solution, then soon as I integrate it into my main solution it doesn't work. LOL
Ok, stupid mistake on my part, all working now. Thanks a bunch Phil! =)