Caro Emg,
Ho letto da qualche parte adesso non ricordo che tu avevi creato una funzione per controllare il codice IBAN. potresti inviarmela
con test minimale per favore ?
Gazie
Moderator: Enrico Maria Giordano
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL cPae := "IT"
LOCAL cAbi := "01234"
LOCAL cCab := "01234"
LOCAL cCon := "000000012345"
LOCAL cCin := CIN( cAbi, cCab, cCon )
? IBAN( "IT", cCin, cAbi, cCab, cCon )
RETURN NIL
STATIC FUNCTION IBAN( cPae, cCin, cAbi, cCab, cCon )
LOCAL cChk := IBANCHK( cPae + "00" + cCin + cAbi + cCab + cCon )
RETURN cPae + cChk + cCin + cAbi + cCab + cCon
STATIC FUNCTION IBANCHK( cIba )
LOCAL cGru, cRes := ""
LOCAL i
cIba = SUBSTR( cIba, 5 ) + LEFT( cIba, 4 )
cIba = IBANNUM( cIba )
FOR i = 1 TO LEN( cIba ) STEP 8
cGru = cRes + SUBSTR( cIba, i, 8 )
cRes = LTRIM( STR( INT( VAL( cGru ) % 97 ) ) )
NEXT
RETURN STRZERO( ( 98 - VAL( cRes ) ) % 97, 2 )
STATIC FUNCTION IBANNUM( cIba )
LOCAL cTmp := cIba
LOCAL cChr
LOCAL i
cIba = ""
FOR i = 1 TO LEN( cTmp )
cChr = SUBSTR( cTmp, i, 1 )
IF ISDIGIT( cChr )
cIba += cChr
ELSE
cIba += LTRIM( STR( ASC( cChr ) - ASC( "A" ) + 10 ) )
ENDIF
NEXT
RETURN cIba
STATIC FUNCTION CIN( cAbi, cCab, cCon )
LOCAL aPari := { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28 }
LOCAL aDisp := { 1, 0, 5, 7, 9, 13, 15, 17, 19, 21, 2, 4, 18, 20, 11, 3, 6, 8, 12, 14, 16, 10, 22, 25, 24, 23, 27, 28, 26 }
LOCAL cNume := "0123456789"
LOCAL cLett := "ABCDEFGHIJKLMNOPQRSTUVWXYZ-. "
LOCAL cCod := UPPER( cAbi + cCab + cCon )
LOCAL nSomma := 0
LOCAL i, n
FOR i = 1 TO LEN( cCod )
n = AT( SUBSTR( cCod, i, 1 ), cNume )
IF n = 0
n = AT( SUBSTR( cCod, i, 1 ), cLett )
ENDIF
IF i % 2 = 0
nSomma += aPari[ n ]
ELSE
nSomma += aDisp[ n ]
ENDIF
NEXT
RETURN SUBSTR( cLett, ( nSomma + 1 ) % 26, 1 )
FUNCTION ISIBAN( cIba )
LOCAL cChk := SUBSTR( cIba, 3, 2 )
cIba = LEFT( cIba, 2 ) + "00" + SUBSTR( cIba, 5 )
RETURN cChk = IBANCHK( cIba )
io avrei per caso in un archivio i codici abi e cab delle banche
indolore potrei andarli a cercare li che dici ?
Return to All products support
Users browsing this forum: No registered users and 18 guests