Ticket #321 (closed defect: fixed)
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
Note: See
TracTickets for help on using
tickets.
![(please configure the [header_logo] section in trac.ini)](/ModelGlue.com/trac.cgi/chrome/site/your_project_logo.png)