by Manuel Aranda » Fri Sep 29, 2006 4:21 pm
Aquí la tienes para clipper:
cBanco:=SPACE(4)
cSucursal:=SPACE(4)
cRefer2:=SPACE(10)
@ 24,0 SAY SPACE(80)
@ 24,4 SAY "Introduzca Banco, Sucursal y N£m. de cuenta......"
DibujaCuadro(11,8,15,70, "W+/B",.T.)
@ 11,10 SAY " CALCULO DE DIGITOS DE CUENTA BANCARIA " COLOR "W+/R"
SetCursor(3)
@ 13,15 SAY " Banco Sucursal DC Cuenta" COLOR "W+/B"
@ 14,15 SAY " [ ] [ ] [ ] [ ]" COLOR "G/B"
@ 14,18 GET cBanco PICTURE "9999" COLOR "GR+/B"
@ 14,28 GET cSucursal PICTURE "9999" COLOR "GR+/B"
@ 14,45 GET cRefer2 PICTURE "9999999999" COLOR "GR+/B"
READ
cRefer1=cBanco+cSucursal
@ 14,38 SAY digBanco(cRefer1,cRefer2) COLOR "W+/R"
*************************************************************************
FUNCTION Digbanco(cRefer1,cRefer2)
*************************************************************************
LOCAL nDigitos := 10
LOCAL aDigito := ARRAY( nDigitos )
LOCAL aPeso := { 1, 2, 4, 8, 5, 10, 9, 7, 3, 6 }
LOCAL nSuma := 0
LOCAL nCont
LOCAL nModulo
LOCAL nResto
LOCAL cDigito1
LOCAL cDigito2
cRefer1 := STRTRAN(cRefer1,'-')
cRefer1 := STRTRAN(cRefer1,'.')
cRefer1 := STRTRAN(cRefer1,'/')
cRefer1 := STRTRAN(cRefer1,' ')
cRefer1 := RIGHT(cRefer1,nDigitos)
cRefer1 := PADL(cRefer1,nDigitos,'0')
cRefer2 := STRTRAN(cRefer2,'-')
cRefer2 := STRTRAN(cRefer2,'.')
cRefer2 := STRTRAN(cRefer2,'/')
cRefer2 := STRTRAN(cRefer2,' ')
cRefer2 := RIGHT(cRefer2,nDigitos)
cRefer2 := PADL(cRefer2,nDigitos,'0')
FOR nCont := 1 to nDigitos
aDigito[ nCont ] := VAL( SUBSTR( cRefer1, nCont, 1 ) )
nSuma += ( aDigito[ nCont ] * aPeso[ nCont ] )
NEXT
nModulo := 11 - INT( nSuma % 11 )
nResto := IF( nModulo == 10, 1, IF( nModulo == 11, 0, nModulo ) )
cDigito1 := LTRIM(STR(nResto))
nSuma := 0
FOR nCont := 1 to nDigitos
aDigito[ nCont ] := VAL( SUBSTR( cRefer2, nCont, 1 ) )
nSuma += ( aDigito[ nCont ] * aPeso[ nCont ] )
NEXT
nModulo := 11 - INT( nSuma % 11 )
nResto := IF( nModulo == 10, 1, IF( nModulo == 11, 0, nModulo ) )
cDigito2 := LTRIM(STR(nResto))
RETURN(cDigito1+cDigito2)