Newsgroup: it.comp.lang.vo-clipper
Titolo: VO 2.7b Codice Fiscale

Ciao a tutti
per caso qualcuno ha un sorgente per il checkdigit del codice fiscale
? Ovviamente in VO
Grazie in anticipo
Paolo Callegari
p.calle...@tiscalinet.it
 (remove xxxx)

   FUNCTION vercf( x) //verifica codice fiscale
LOCAL s,i,d AS USUAL
LOCAL r,st,cod,par AS STRING
cod:=x
s:=0
FOR i:=2 TO 14 STEP 2
 r:=SubStr(cod,i,1)
  IF r="A" .or. r="0"
    s:=s+0
  ELSEIF r="B" .or. r="1"
    s:=s+1
  ELSEIF r="C" .or. r="2"
    s:=s+2
  ELSEIF r="D" .or. r="3"
    s:=s+3
  ELSEIF r="E" .or. r="4"
    s:=s+4
  ELSEIF r="F" .or. r="5"
    s:=s+5
  ELSEIF r="G" .or. r="6"
    s:=s+6
  ELSEIF r="H" .or. r="7"
    s:=s+7
  ELSEIF r="I" .or. r="8"
    s:=s+8
  ELSEIF r="J" .or. r="9"
    s:=s+9
  ELSEIF r="K"
    s:=s+10
  ELSEIF r="L"
    s:=s+11
  ELSEIF r="M"
    s:=s+12
  ELSEIF r="N"
    s:=s+13
  ELSEIF r="O"
    s:=s+14
  ELSEIF r="P"
    s:=s+15
  ELSEIF r="Q"
    s:=s+16
  ELSEIF r="R"
    s:=s+17
  ELSEIF r="S"
    s:=s+18
  ELSEIF r="T"
    s:=s+19
  ELSEIF r="U"
    s:=s+20
  ELSEIF r="V"
    s:=s+21
  ELSEIF r="W"
    s:=s+22
  ELSEIF r="X"
    s:=s+23
  ELSEIF r="Y"
    s:=s+24
  ELSEIF r="Z"
    s:=s+25
ENDIF
NEXT
FOR i=1 TO 15 STEP 2
 r:=SubStr(cod,i,1)
  IF r="A" .or. r="0"
    s:=s+1
  ELSEIF r="B" .or. r="1"
    s:=s+0
  ELSEIF r="C" .or. r="2"
    s:=s+5
  ELSEIF r="D" .or. r="3"
    s:=s+7
  ELSEIF r="E" .or. r="4"
    s:=s+9
  ELSEIF r="F" .or. r="5"
    s:=s+13
  ELSEIF r="G" .or. r="6"
    s:=s+15
  ELSEIF r="H" .or. r="7"
    s:=s+17
  ELSEIF r="I" .or. r="8"
    s:=s+19
  ELSEIF r="J" .or. r="9"
    s:=s+21
  ELSEIF r="K"
    s:=s+2
  ELSEIF r="L"
    s:=s+4
  ELSEIF r="M"
    s:=s+18
  ELSEIF r="N"
    s:=s+20
  ELSEIF r="O"
    s:=s+11
  ELSEIF r="P"
    s:=s+3
  ELSEIF r="Q"
    s:=s+6
  ELSEIF r="R"
    s:=s+8
  ELSEIF r="S"
    s:=s+12
  ELSEIF r="T"
    s:=s+14
  ELSEIF r="U"
    s:=s+16
  ELSEIF r="V"
    s:=s+10
  ELSEIF r="W"
    s:=s+22
  ELSEIF r="X"
    s:=s+25
  ELSEIF r="Y"
    s:=s+24
  ELSEIF r="Z"
    s:=s+23
ENDIF
NEXT
st:="BCDEFGHIJKLMNOPQRSTUVWXYZ"
d:=INT(s/26)
d:=d*26
s:=s-d
IF s=0
r:="A"
ELSE
r:=SubStr(st,s,1)
ENDIF
   IF Right(cod,1)=r
    RETURN(.t.)
    ELSE
    RETURN(.f.)
    ENDIF
ciao
--------------------------------
Inviato via 
http://arianna.libero.it/usenet/

 wrote in message 
news:uer5b2lmd6hn23vfl...@4ax.com...


Ciao da Massimo Martino
FUNCTION m_IsCF(cCodFisc AS STRING) AS LOGIC PASCAL
	LOCAL nTimes      := 0		AS SHORTINT
	LOCAL cSingoloCar := ""		AS STRING
	LOCAL nOddCheck   := 0		AS SHORTINT
	LOCAL nEvenCheck  := 0		AS SHORTINT
	LOCAL aCheckPari  := {}		AS ARRAY
	LOCAL lCodOK      := TRUE	AS LOGIC
	LOCAL nCheck				AS SHORTINT
	AAdd(aCheckPari, 01)
	AAdd(aCheckPari, 00)
	AAdd(aCheckPari, 05)
	AAdd(aCheckPari, 07)
	AAdd(aCheckPari, 09)
	AAdd(aCheckPari, 13)
	AAdd(aCheckPari, 15)
	AAdd(aCheckPari, 17)
	AAdd(aCheckPari, 19)
	AAdd(aCheckPari, 21)
	AAdd(aCheckPari, 02)
	AAdd(aCheckPari, 04)
	AAdd(aCheckPari, 18)
	AAdd(aCheckPari, 20)
	AAdd(aCheckPari, 11)
	AAdd(aCheckPari, 03)
	AAdd(aCheckPari, 06)
	AAdd(aCheckPari, 08)
	AAdd(aCheckPari, 12)
	AAdd(aCheckPari, 14)
	AAdd(aCheckPari, 16)
	AAdd(aCheckPari, 10)
	AAdd(aCheckPari, 22)
	AAdd(aCheckPari, 25)
	AAdd(aCheckPari, 24)
	AAdd(aCheckPari, 23)
    cCodFisc := Upper(cCodFisc)
	IF Len(cCodFisc) <> 16
		RETURN FALSE
	ENDIF
	nTimes := 1
	DO WHILE nTimes <= 15 .AND. lCodOk
		cSingoloCar := SubStr(cCodFisc, nTimes, 1)
		DO CASE
			CASE Asc(PSZ(cSingoloCar)) >= 48 .AND. Asc(PSZ(cSingoloCar)) <= 57
// E' un numero
				nOddCheck := nOddCheck + aCheckPari[Asc(PSZ(cSingoloCar)) - 47]
			CASE Asc(PSZ(cSingoloCar)) >= 65 .AND. Asc(PSZ(cSingoloCar)) <= 90
				nOddCheck := WORD(nOddCheck) + aCheckPari[Asc(PSZ(cSingoloCar)) -
64]
			OTHERWISE
				lCodOK := FALSE
		ENDCASE
		nTimes += 2
	ENDDO
	nTimes := 2
	DO WHILE nTimes <= 14 .AND. lCodOk
		cSingoloCar := SubStr(cCodFisc, nTimes, 1)
    	DO CASE
			CASE Asc(PSZ(cSingoloCar)) >= 48 .AND. Asc(PSZ(cSingoloCar)) <= 57
// E' un numero
				nEvenCheck := nEvenCheck + Val(cSingoloCar)
			CASE Asc(PSZ(cSingoloCar)) >= 65 .AND. Asc(PSZ(cSingoloCar)) <= 90
				nEvenCheck := nEvenCheck + Asc(PSZ(cSingoloCar)) - 65
			OTHERWISE
				lCodOK := FALSE
		ENDCASE
		nTimes += 2
	ENDDO
	nCheck := (nOddCheck + nEvenCheck) % 26
	lCodOk := ( CHR(WORD(nCheck) + 65) == Right(cCodFisc, 1) )
RETURN (lCodOk)

Grazie a tutti
Ora faccio prove.
Paolo Callegari