Your script does a go to field with every character scanned. Put Go to field before the end if and then you may need to end your script with an exit Script [False] step to cancel out the appended tab character.
Thanks Phil,Do you mean every Barcode character? because I thought that the if statement is only true when the TriggerKeyStroke = 9, could you maybe suggest a better way of scripting this?
Yes, I mean every character. Your go to field step is outside of the If block and thus the go to field step is executed every time a character is entered into your field.
You may find the example scripts used here to be helpful: Need help writing script to integrate barcode scanning
The exit Script [False] did the trick, it is strange to me that the script will trigger with no tab entered.
Thanks for your help
USB connected scanners almost always function in "keyboard emulation mode". This mode enables the computer to respond to scanner input as though a very, very fast typist entered the data scanned from the bar code. Your script is triggered with every single character input from the scanner, not just the tab key.
In your original script:
If [ Code ( Get(TriggerKeystroke) ) = 9 ]
Set Variable [ $Scan; Value:Training::Barcode Global ]
If [ $Scan = "ENDSCAN" ]
Exit Script [ ]
Clear [ Training::Barcode Global ] [ Select ]
Set Field [ Training::Contact Index; $Scan ]
Enter Find Mode [ ]
Set Field [ Training::Scan Date; Get ( CurrentDate ) ]
Perform Find [ ]
Sort Records by Field [ Descending; Training::Training Index ]
Go to Record/Request/Page [ First ]
Go to Field [ Training::Barcode Global ]
The code in blue is only executed when the charcacter entered is a tab character. the text in black is executed with every character scanned off the label and also the appended "tab" suffix.
I think the combination of go to field and no exit script [false] step resulted in the script tripping it's own script trigger in an infinite loop due to the fact that this trigger performs a script before FileMaker processes the triggering event (a keystroke). Exit Script [False] breaks that loop by causing FileMaker to not process the triggering event.