Ticket #321 (closed defect: fixed)

Opened 17 years ago

Last modified 17 years ago

helpers/strLib.cfm failed on CF7 environments

Reported by: DanWilson Owned by:
Priority: normal Milestone: 3.0
Version: 3.0.178 Severity: minor
Keywords: Cc:

Description (last modified by cfgrok) (diff)

Originally posted by Dan Wilson on 5/14/2008 at 9:48 AM: entered by Ezra Parker on port to new system

The isVIN function included in the string library made use of cf8 specific operators.

The old Function:

function isVIN(v) {
    var i = "";
    var d = "";
    var f = "";
    var p = "";
    var cd = "";
    var LL = "A,B,C,D,E,F,G,H,J,K,L,M,N,P,R,S,T,U,V,W,X,Y,Z";
    var VL = "1,2,3,4,5,6,7,8,1,2,3,4,5,7,9,2,3,4,5,6,7,8,9";
    var FL = "8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2";
    var rs = 0;

    if(len(v) != 17) {return false;}
    for(i = 1; i <= 17; i++){
        f = ListGetAt(FL, i);
        d = Mid(v,i,1);
        if(IsNumeric(d)){
            d *= f;
        }
        else{
            p = ListFindNoCase(LL,d);
            d = ListGetAt(VL,p);
            d *= f;
        }
        rs += d;
    }
    cd = rs % 10;
    if(cd == 0){cd = "x";}
    if(cd == Mid(v,9,1)){return true;}
    return false;
}

The Updated function:

function isVIN(v) {
    var i = "";
    var d = "";
    var f = "";
    var p = "";
    var cd = "";
    var LL = "A,B,C,D,E,F,G,H,J,K,L,M,N,P,R,S,T,U,V,W,X,Y,Z";
    var VL = "1,2,3,4,5,6,7,8,1,2,3,4,5,7,9,2,3,4,5,6,7,8,9";
    var FL = "8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2";
    var rs = 0;

    if(len(v) NEQ 17) {return false;}
    for(i = 1; i LTE 17; i = i + 1){
        f = ListGetAt(FL, i);
        d = Mid(v,i,1);
        if(IsNumeric(d)){
            d = d*f;
        }
        else{
            p = ListFindNoCase(LL,d);
            d = ListGetAt(VL,p);
            d = d*f;
        }
        rs =rs + d;
    }
    cd = rs mod 10;
    if(cd IS 0){cd = "x";}
    if(cd IS Mid(v,9,1)){return true;}
    return false;
}

Change History

Changed 17 years ago by cfgrok

  • status changed from new to closed
  • resolution set to fixed
  • description modified (diff)

Originally posted by Dan Wilson on 10/28/2008 at 9:56 AM: entered by Ezra Parker on port to new system

Removed the helpers from the distro. People can roll their own.

Note: See TracTickets for help on using tickets.