bousaid

WINDEV PROCEDURE Cle & RIP CCP 2021

Aug 2nd, 2021 (edited)
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. //Usage:
  2. //SAI_CleCCP = Cle_CCP_RIP("OLD",SAI_CompteCCP)
  3. //SAI_CleRIP = Cle_CCP_RIP("RIP",SAI_CompteCCP)
  4.  
  5. PROCEDURE PUBLIC GLOBAL Cle_CCP_RIP(Type_Cle is string, Compte_CCP is string):string
  6.  
  7. nResulta is int
  8. sCle is string = "00"
  9.  
  10. SWITCH Type_Cle
  11. // Cle CCP
  12. CASE "OLD"
  13. FOR I = Length(Compte_CCP) TO 1 STEP -1
  14. nResulta = (nResulta + Val(Compte_CCP[I]) * (Length(Compte_CCP) - I + 4))
  15. nResulta = modulo(nResulta, 100)
  16. END
  17. // Cle Rip
  18. CASE "RIP"
  19. nResulta = (97 - ((((modulo(Val(Compte_CCP), 97)) * modulo(3, 97)) + 85) modulo 97))
  20. OTHER CASE
  21. nResulta = 0
  22. END
  23.  
  24. //ADD "0" Like 01, 02, 03 ... etc
  25. sCle = NumToString(nResulta,"02d")
  26. Compte_CCP = NumToString(Val(Compte_CCP),"010d")
  27.  
  28. RESULT sCle
Add Comment
Please, Sign In to add comment