/* Filename:    J008_onDecodeOverload.js
 * Description: OnDecode overload example (to modify decode data)
 * Copyright:   2006 The Code Corporation. Please see http://www.codecorp.com/jsLicensing.html for information regarding copyright and grant of license.
 * $Revision: 118 $
 * $Date: 2006-12-05 16:26:51 -0700 (Tue, 05 Dec 2006) $
 */
 
include(".crx.js");

reader.OnDecodeOld = reader.onDecode;

reader.onDecode = function(decode)
{
    if( decode.data.substr(0, 3) == "abc" ) // Matches for data begining with abc
    {
        //remove the "abc" from the beginning
        decode.data = decode.data.substr(3);
        
        //replace all Z chars with DE
        re = /Z/g;
        decode.data = decode.data.replace(re, "DE"); 
        
        //after 1st 5 char add CDE, add rest of the data starting at the 7th char
        decode.data = decode.data.substr(0,5) + "CDE" + decode.data.substr(6);
    }
    
     return reader.onDecodeOld(decode); //let the original onDecode function handle everything else.
}

//EOF