Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #5572 > unrolled thread

IBAN calculation

Started bymaduet@bluewin.ch
First post2013-07-24 06:21 -0700
Last post2013-07-25 22:46 +0200
Articles 4 — 4 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  IBAN calculation maduet@bluewin.ch - 2013-07-24 06:21 -0700
    Re: IBAN calculation dlzc <dlzc1@cox.net> - 2013-07-24 07:53 -0700
    Re: IBAN calculation "Wolfgang Riedmann" <wriedmann@gmail.com> - 2013-07-24 18:33 +0200
    Re: IBAN calculation D.J.W. van Kooten <public@ic2remove.this.com> - 2013-07-25 22:46 +0200

#5572 — IBAN calculation

Frommaduet@bluewin.ch
Date2013-07-24 06:21 -0700
SubjectIBAN calculation
Message-ID<d892c631-b8c6-4f60-82a0-d9a984e4adc2@googlegroups.com>
Has anyone ever tried calculating IBAN's with VO 2.8 ? How to deal with 24-digit long integers ? Does anyone know of a function that might work ? Grateful for any hints ...

[toc] | [next] | [standalone]


#5574

Fromdlzc <dlzc1@cox.net>
Date2013-07-24 07:53 -0700
Message-ID<5096d7eb-b90e-4429-a80f-072b7df3359b@googlegroups.com>
In reply to#5572
Dear mad...:

On Wednesday, July 24, 2013 6:21:26 AM UTC-7, mad...@bluewin.ch wrote:
> Has anyone ever tried calculating IBAN's with VO 2.8 ?
> How to deal with 24-digit long integers ? Does anyone
> know of a function that might work ? Grateful for any
> hints ...

Process 1 - 4 characters at a time.  Carry 24 to 6 integers with the value.  Zero fill lower order integers.

Can you not just treat it as a string?  Do you actually need to do math / logic with it?

You can always pass it on to a 3rd party app...
http://apps.microsoft.com/windows/en-us/app/iban-validation/8aa8fc0e-56b7-47e9-97bb-4e2e8f033c75

David A. Smith

[toc] | [prev] | [next] | [standalone]


#5578

From"Wolfgang Riedmann" <wriedmann@gmail.com>
Date2013-07-24 18:33 +0200
Message-ID<b5adtrFnfgaU1@mid.individual.net>
In reply to#5572
Hi Martin,

> Has anyone ever tried calculating IBAN's with VO 2.8 ? How to deal
> with 24-digit long integers ? Does anyone know of a function that
> might work ? Grateful for any hints ...

look at this code:

function IBANrechnen( cLand := "IT" as string, cCin as string, cAbi as
string, cCab as string, cKonto as string ) as string pascal

	local cCheck			as string
	local cIBAN				as string
	            
	if Empty( cCin )
		cCin			:= CINRechnen( cAbi, cCab, cKonto )
	endif	            
	cCheck			:= IBANCheck( cLand + "00" + cCin + PadL( cAbi, 5, "0" ) +
PadL( cCab, 5, "0" ) + PadL( cKonto, 12, "0" ) )
	cIBAN			:= cLand + cCheck + cCin + PadL( cAbi, 5, "0" ) + PadL( cCab,
5, "0" ) + PadL( cKonto, 12, "0" )

    return cIBAN

function IBANCheck( cIBAN as string ) as string pascal

	local cGru			as string
	local cRest			as string
// 	local nI			as dword
// 	local nLen			as dword
	local cReturn		as string
	local nRest			as dword
	local nWert			as dword

	cGru			:= ""
	cRest			:= ""
	cIBAN			:= SubStr2( cIBAN, 5 ) + Left( cIBAN, 2 ) + "00" // Left(
cIBAN, 4 )
	_DebOut32( psz( "IBAN: " + cIBAN ) )	
	cIBAN			:= IBANNummer( cIBAN )
	//_DebOut32( psz( "IBAN numerisch: " + cIBAN ) )	
	// Zahl ist zu lang für normale Berechnung
	cRest			:= cIBAN
	nWert			:= 0
	while ! Empty( cRest )
		nWert			:= nRest * 10 + Val( Left( cRest, 1 ) )
		cRest			:= SubStr2( cRest, 2 )
		nRest			:= nWert % 97
		//_DebOut32( psz( "Wert: " + NTrim( nWert ) + " % 97 ergibt " +
NTrim( nRest ) ) )
	end
	cReturn			:= StrZero( 98 - nRest, 2 ) 
	
	// geht nicht
// 	nLen			:= SLen( cIBAN )
// 	for nI := 1 upto nLen step 8
// 		cGru			:= cRest + SubStr3( cIBAN, nI, 8 )
// 		cRest			:= NTrim( Integer( Val( cGru ) % 97 ) )
// 	next
// 	cReturn			:= StrZero( ( 98 - Val( cRest ) ) % 97, 2 )	
	//_DebOut32( psz( "Prüfung: " + cReturn ) )	

    return cReturn
    
function IBANNummer( cIBAN as string ) as string pascal

	local cTemp			as string
	local cChar			as string
	local nI			as dword
	local nLen			as dword 

	cTemp			:= cIBAN
	cIBAN			:= ""
	nLen			:= SLen( cTemp )
	for nI := 1 upto nLen
		cChar			:= SubStr( cTemp, nI, 1 )
		if IsDigit( String2PSZ( cChar ) )
			cIBAN			:= cIBAN + cChar
		else
			cIBAN			:= cIBAN + Str3( Asc( cChar ) - Asc( "A" ) + 10, 2, 0 )
		endif
	next

    return cIBAN
    

Wolfgang


-- 

[toc] | [prev] | [next] | [standalone]


#5585

FromD.J.W. van Kooten <public@ic2remove.this.com>
Date2013-07-25 22:46 +0200
Message-ID<jl33v8170s4fm2273so550u42evp9ukpv9@4ax.com>
In reply to#5572
On Wed, 24 Jul 2013 06:21:26 -0700 (PDT), maduet@bluewin.ch wrote:

>Has anyone ever tried calculating IBAN's with VO 2.8 ? How to deal with 24-digit long integers ? 
>Does anyone know of a function that might work ? Grateful for any hints ...

The function below is from Norbert Kolk , posted in this NG last year.
This is how we use it

Dick

FUNCTION CheckIBAN(cIban AS STRING, lInfo AS LOGIC) AS LOGIC
//#s To check the IBAN nr Norbert Kolk NG 13-7-2012, added 13-8-2012
//#s
//#x
//#l
//#l
//#l
//#l
//#p
//#p
//#r
//#e
//#e
LOCAL lOK		AS LOGIC
LOCAL nP			AS INT
LOCAL cTemp		AS STRING
LOCAL cC			AS STRING
LOCAL cLand		AS STRING
LOCAL aTemp		AS ARRAY
LOCAL i 			AS DWORD
LOCAL nLen		AS DWORD
LOCAL cError 	AS STRING 
LOCAL nMust 	AS DWORD
	
	cIban := AllTrim(Upper(StrTran(cIban," ","")))
	lOK:=FALSE
	
	IF Empty(cIban)
		cError:=tVt("MSG_NOTHINGENTERED","Niets
ingevuld","Nothing entered")
	ELSEIF Between(Asc(Left(cIban, 1)), 48, 57) // erstes Zeichen
ist eine Ziffer
		cError:=tVt("MSG_STARTWITHCOUNTRY","Start met 2
letters (landcode)","Start with 2 letters (country code)")
	ELSEIF Between(Asc(Left(cIban, 1)), 65, 90) .AND.
Between(Asc(SubStr(cIban, 2, 1)), 65, 90)
		IF !Between(SLen(cIban), 15, 31)
			cError:=tVt("msg_lengthbetween1531","Lengte
moet tussen 15 en 31 tekens zijn","Length must be between 15 and 31
characters")
		ELSE
			// Albanien AL47212110090000000235698741 5 -
12	28
			// Andorra AD1200012030200359100100 5 - 12
24
			// Belgien BE62510007547061 5 - 7 16
			// Bosnien und 	Herzegowina
BA391290079401028494	5 - 11	20
			// Bulgarien		BG80BNBG96611020345678
5 - 12	22
			// Dänemark DK5000400440116243 5 - 8 18
			// Deutschland		DE89370400440532013000
5 - 12	22
			// Estland EE975500000550008329 5 - 8
20
			// Finnland FI2112345600000785 5 - 10	18
			// Faroer Insel	FO2000400440116243 5 - 8 18
			// Frankreich FR1420041010050500013M02606 5 -
14	27
			// Gibraltar GI75NWBK000000007099453 5 - 8
23
			// Griechenland	GR1601101250000000012300695 5
- 11	27
			// Grönland GL2000400440116243 5 - 8 18
			// Großbritannien	GB29NWBK60161331926819
5 - 8		22
			// Irland IE29AIBK93115212345678 5 - 8
22
			// Island IS140159260076545510730339 5 - 8
26
			// Italien IT40S0542811101000000123456 6 - 15
27
			// Kroatien HR1210010051863000160 5 - 11
21
			// Lettland LV80BANK0000435195001 5 - 8
21
			// Litauen LT121000011101001000 5 - 9
20
			// Luxemburg		LU280019400644750000 5
- 7		20
			// Malta MT84MALT011000012345MTLCAST001S 5 -
13	31
			// Mazedonien		MK07250120000058984 5
- 8		19
			// Mauritius MU17BOMM0101101030300200000MUR 5
- 11	30
			// Monaco MC9320041010050500013M02606 5 - 14
27
			// Niederlande		NL39RABO0300065264 5 -
8		18
			// Norwegen NO9386011117947 5 - 8 15
			// Österreich		AT617601300035746811 5
- 9		20
			// Polen PL61109010140000071219812874 5 - 12
28
			// Portugal PT50000201231234567890154 5 - 12
25
			// Rumänien* RO83UNCR0100xxxxxx771USD 5 - 8
24
			// San Marino SM68S0542811101000000123456 6 -
15	27
			// Saudi-Arabien SA5655000000000570400546 5 -
6		24
			// Schweden SE3550000000054910000003 5 - 7
24
			// Schweiz CH9300762011623852957 5 - 9
21
			// Slowakei SK3112000000198742637541 5 - 8
24
			// Slowenien		SI56191000000123438 5
- 9		19
			// Spanien ES0700120345030000067890 5 - 12
24
			// Tschechien CZ6508000000192000145399 5 - 8
24
			// Türkei TR760006100519786457841326 5 - 10
26
			// Ungarn HU42117730161111101800000000 5 - 11
28
			// Zypern CY17002001280000001200527600 5 - 12
28

			// DE68210501700012345678

			nLen	:= SLen(cIban)
			cLand	:= SubStr(cIban, 1, 2)
			DO CASE
			CASE Instr(cLand, "BE")
				nMust:=16
			CASE Instr(cLand, "DK,FI,FO,GL,NL")
				nMust:=18
			CASE Instr(cLand, "MK,SI")
				nMust:=19
			CASE Instr(cLand, "HR,LV,CH,LI")
				nMust:=21
			CASE Instr(cLand, "GI")
				nMust:=23
			CASE Instr(cLand, "AD,RO,SA,SE,SK,ES,CZ")
				nMust:=24
			CASE Instr(cLand, "PT")
				nMust:=25
			CASE Instr(cLand, "IS,TR")
				nMust:=26
			CASE Instr(cLand, "FR,GR,IT,MC,SM")
				nMust:=27
			CASE Instr(cLand, "AL,PL,HU,CY")
				nMust:=28
			CASE Instr(cLand, "MU")
				nMust:=30
			CASE Instr(cLand, "MT")
				nMust:=31
			ENDCASE				

			IF nLen = 20 .AND. Instr(cLand,
"AT,BA;EE,LT,LU")
				lOK := TRUE
			ELSEIF nLen = 22 .AND. Instr(cLand,
"DE,BG,GB,IE")
				lOK := TRUE
			ELSEIF nLen = 15 .AND. Instr(cLand, "NO")
				lOK := TRUE
			ELSEIF nLen = 16 .AND. Instr(cLand, "BE")
				lOK := TRUE
			ELSEIF nLen = 18 .AND. Instr(cLand,
"DK,FI,FO,GL,NL")
				lOK := TRUE
			ELSEIF nLen = 19 .AND. Instr(cLand, "MK,SI")
				lOK := TRUE
			ELSEIF nLen = 21 .AND. Instr(cLand,
"HR,LV,CH,LI")
				lOK := TRUE
			ELSEIF nLen = 23 .AND. Instr(cLand, "GI")
				lOK := TRUE
			ELSEIF nLen = 24 .AND. Instr(cLand,
"AD,RO,SA,SE,SK,ES,CZ")
				lOK := TRUE
			ELSEIF nLen = 25 .AND. Instr(cLand, "PT")
				lOK := TRUE
			ELSEIF nLen = 26 .AND. Instr(cLand, "IS,TR")
				lOK := TRUE
			ELSEIF nLen = 27 .AND. Instr(cLand,
"FR,GR,IT,MC,SM")
				lOK := TRUE
			ELSEIF nLen = 28 .AND. Instr(cLand,
"AL,PL,HU,CY")
				lOK := TRUE
			ELSEIF nLen = 30 .AND. Instr(cLand, "MU")
				lOK := TRUE
			ELSEIF nLen = 31 .AND. Instr(cLand, "MT")
				lOK := TRUE
			ENDIF

			IF lOK
				cTemp := SubStr(cIban, 5) +
SubStr(cIban, 1, 4)
				FOR i := 1 UPTO SLen(cTemp) //
210501700012345678DE68 // Buchstaben werden durch Zahlenwerte,
Position im Alphabet + 9, ersetzt
					cC := SubStr(cTemp, i, 1)
					IF Between(cC, "A", "Z")
						cTemp := SubStr(cTemp,
1 , i-1) + NTrim(Asc(cC)-55) + SubStr(cTemp, i+1)
						i += 1
					ENDIF
				NEXT
				
				aTemp := {}
				
				WHILE cTemp <> NULL_STRING //
Zerlegung in 4er-Gruppen von rechts her
					AAdd(aTemp, Val(Right(cTemp,
4)))
					IF SLen(cTemp) > 4
						cTemp := SubStr(cTemp,
1, SLen(cTemp)-4)
					ELSE
						cTemp := NULL_STRING
					ENDIF
				ENDDO
				nP := 0
				FOR i := 1 UPTO ALen(aTemp)
					// wir nützen die Rechenregeln
für Modulo aus
					// (a + b) mod m = (a mod m) +
(b mod m)
					// (a * b) mod m = (a mod m) *
(b mod m)
					// 10.000 mod 97 = 9
					nP := (nP + ((aTemp[i] % 97) *
(9^(i-1)))) % 97 // c Log2DB(FloatFormat(9^(i-1),20,0))
				NEXT
				IF nP = 1 // Prüfzahl modulo 97 muss 1
sein
					lOK := TRUE
				ELSE
 cError:=tVt("MSG_INCORRECTCONTROLNR","Verkeerd controle
cijfer","Wrong check digit")
					lOK:=FALSE
				ENDIF
			ELSE
 cError:=tVt("msg_wrongnrforcountry","Verkeerde lengte voor dit
land","Wrong length for this country")+"
"+NTrim(nLen)+"->"+NTrim(nMust)
				lOK:=FALSE 			ENDIF
// Lok
		ENDIF // Length between 15-31
	ENDIF
	
	IF !lOK .AND. lInfo
		IF Empty(cError)
			cError:=tVt("MSG_INVALIDACCOUNT","Ongeldig
rekeningnummer","Invalid account")
		ENDIF
		cError:="IBAN: "+cError
		ErrorBox{,cError}:Show()
	ENDIF

RETURN lOK

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web