D028868 CR1500 CR1100 CR2700 JavaScript Programming Guide User Manual Page 30 of 41
The Code Corporation
12393 South Gateway Park Place, Suite 600, Draper, UT 84020
+1 (801) 495-2200
FAX +1 (801) 495-0280
reader.onDecodeAttempt(count)
This function checks for a function variable “rules_onDecodeAttempt” and if it is not “null”, it
will call that function.
reader.onDecode(decode)
This function checks for a function variable “rules_onDecode” and if it is not “null”, it will call
that function. If “rules_onDecode” does not return false, the function will handle the decode.
reader.onDecodes(decodes)
This function checks for a function variable “rules_onDecodes” and if it is not “null”, it will call
that function. If “rules_onDecodes” does not return false, and “rules_onDecodeAttempt”
does not return false, this function will process the decodes by calling
reader.onDecode() for each decode object in the decodes array.
reader.onConfigure(data)
This function checks for a function variable “rules_onConfigure” and if it is not “null”, it will
call that function. If “rules_onConfigure” returns true, this function returns immediately. If
“rules_onConfigure” returns false, this function will attempt to process the configuration data
and return true if processed, otherwise false.
.codeRules.js
Code provides the ability to define a “.codeRules.js” file, which can specify functionality for the listed
methods.
rules_onDecodes
The decodes array object (Section 13.1.4) is passed into the function and may be returned by
the function. If a Boolean false is returned by the function, the reader will prevent further
processing of the decode. The Code reader will initially indicate a good read as soon as a bar
code is found.
The rules_onDecodes() function must return either the decodes array object or the
value ‘false’. Returning ‘false’ will stop further action by the reader.onDecodes()
function.
This example illustrates using regular expression to replace each uppercase letter ‘A’ in the
decode string with lowercase letter ‘a’. The properties of the Decode object are described in
Section 4.
Example:
rules_onDecodes = function(decodes)
{
decodes[0].data.replace(/A/g, “a”);
return decodes;
};