ter-pierre Posted December 30, 2005 Share Posted December 30, 2005 I have the vaconvert.au3 and is very good. Any one knows about some thing like this that do the same with .js scripts? Pierre Link to comment Share on other sites More sharing options...
seandisanti Posted December 30, 2005 Share Posted December 30, 2005 I have the vaconvert.au3 and is very good.Any one knows about some thing like this that do the same with .js scripts?Pierredon't know if there's a UDF but if you post your .js code someone can probably translate it for you. Link to comment Share on other sites More sharing options...
ter-pierre Posted December 30, 2005 Author Share Posted December 30, 2005 well... here is it // the function receives as a parameter an string function checaCPF (CPF) { if (CPF.length != 11 || CPF == "00000000000" || CPF == "11111111111" || CPF == "22222222222" || CPF == "33333333333" || CPF == "44444444444" || CPF == "55555555555" || CPF == "66666666666" || CPF == "77777777777" || CPF == "88888888888" || CPF == "99999999999") return false; soma = 0; for (i=0; i < 9; i ++) soma += parseInt(CPF.charAt(i)) * (10 - i); resto = 11 - (soma % 11); if (resto == 10 || resto == 11) resto = 0; if (resto != parseInt(CPF.charAt(9))) return false; soma = 0; for (i = 0; i < 10; i ++) soma += parseInt(CPF.charAt(i)) * (11 - i); resto = 11 - (soma % 11); if (resto == 10 || resto == 11) resto = 0; if (resto != parseInt(CPF.charAt(10))) return false; return true; } Link to comment Share on other sites More sharing options...
seandisanti Posted December 30, 2005 Share Posted December 30, 2005 well... here is it // the function receives as a parameter an string function checaCPF (CPF) { if (CPF.length != 11 || CPF == "00000000000" || CPF == "11111111111" || CPF == "22222222222" || CPF == "33333333333" || CPF == "44444444444" || CPF == "55555555555" || CPF == "66666666666" || CPF == "77777777777" || CPF == "88888888888" || CPF == "99999999999") return false; soma = 0; for (i=0; i < 9; i ++) soma += parseInt(CPF.charAt(i)) * (10 - i); resto = 11 - (soma % 11); if (resto == 10 || resto == 11) resto = 0; if (resto != parseInt(CPF.charAt(9))) return false; soma = 0; for (i = 0; i < 10; i ++) soma += parseInt(CPF.charAt(i)) * (11 - i); resto = 11 - (soma % 11); if (resto == 10 || resto == 11) resto = 0; if (resto != parseInt(CPF.charAt(10))) return false; return true; }here ya go... // the function receives as a parameter an string Func checaCPF ($CPF) { if Not StringLen($CPF) = 11 Or $CPF = "00000000000" Or $CPF = "11111111111" Or $CPF = "22222222222" Or $CPF = "33333333333" Or $CPF = "44444444444" Or $CPF = "55555555555" Or $CPF = "66666666666" Or $CPF = "77777777777" Or $CPF = "88888888888" Or $CPF = "99999999999") Then Return (0) $soma = 0; for $i=0 to 8 $soma += Int(StringMid($CPF,$i,1) * (10 - i) $resto = 11 - Mod($soma,11) if $resto = 10 Or $resto = 11 Then $resto = 0 if Not $resto = Int(StringMid($CPF,9,1)) Then Return(0) $soma = 0; for $j = 0 to 9 $soma += Int(StringMid($CPF,$j,1)) * (11 - $j) $resto = 11 - Mod($soma,11) if $resto = 10 Or $resto = 11 Then $resto = 0 if Not $resto = Int(StringMid($CPF,10,1))Then return(0) Return(1) EndFunc Link to comment Share on other sites More sharing options...
ter-pierre Posted December 30, 2005 Author Share Posted December 30, 2005 Thak you boy! Link to comment Share on other sites More sharing options...
seandisanti Posted December 30, 2005 Share Posted December 30, 2005 Thak you boy!np, glad to help. Link to comment Share on other sites More sharing options...
LxP Posted December 31, 2005 Share Posted December 31, 2005 (edited) Small logic glitch: if Not StringLen($CPF) = 11 Or ... Equivalent to: If (Not StringLen($CPF)) = 11 Or ... Evaluates to: ; Either: If 0 = 11 Or ...; for non-empty strings ; Or: If 1 = 11 Or ...; for empty strings Therefore needs brackets: If Not (StringLen($CPF) = 11) Or ... Better still: If StringLen($CPF) <> 11 Or ... Edited December 31, 2005 by LxP Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now