User manual - Scripting_Guide

NAURTECH SMART CLIENTS FOR WINDOWS CE AND POCKET PC
CETerm Scripting Guide Page 17
// Prefix zeros to short barcodes
if (data.length == 8)
{
data = "000" + data;
}
// Send barcode to emulator
CETerm.SendText( data, session );
// Return 1 if handled data here
return 1;
}
The following OnBarcodeRead handler will split any barcode containing an ASCII
Linefeed (LF = 0x0A) character and terminated with an ASCII ENQ (ENQ = 0x05)
into two parts. The first part is put into the current IBM 5250 field and the second
part into the next field and then submitted to the IBM host. This technique is
used to login a user with a Code39 barcode in full-ASCII mode. All other
barcodes are passed on for normal input
/* OnBarcodeRead */
function OnBarcodeRead( session, data, source, type, date, time )
{
// Look for Full-ASCII Code 39 (LF = 0x0A) to mark Field Exit
var lfIndex = data.indexOf( "\x0A" );
if (lfIndex >= 0 )
{
var passwordStart = lfIndex + 1;
// Look for Full-ASCII Code 39 (ENQ = 0x05)
var enqIndex = data.lastIndexOf( "\x05" );
if (enqIndex >= 0)
{
// NOTE: Using substr to extract user
// Send User
CETerm.SendText( data.substr( 0, lfIndex ), session );
// Send field exit to advance cursor
CETerm.SendIDA( "IDA_FIELD_EXIT", session );
// Send Password
// NOTE: Using substring to extract password
CETerm.SendText( data.substring( passwordStart,
enqIndex ), session );
// Submit form
CETerm.SendIDA( "IDA_ENTER", session );