bousaid

WINDEV PROCEDURE chiffres_en_lettres_ar

Aug 10th, 2020 (edited)
314
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PROCEDURE chiffres_en_lettres_ar(x)
  2. c,Letter1,Letter2,Letter3,Letter4,Letter5,Letter6 are strings
  3. c1,c2,c3,c4,c5,c6 are int
  4.  
  5. c = NumToString(x, "012d")
  6.  
  7. c1 = Val(Middle(c,12, 1))
  8. SWITCH c1
  9. CASE 1: Letter1 = "واحد"
  10. CASE 2: Letter1 = "اثنان"
  11. CASE 3: Letter1 = "ثلاثة"
  12. CASE 4: Letter1 = "أربعة"
  13. CASE 5: Letter1 = "خمسة"
  14. CASE 6: Letter1 = "ستة"
  15. CASE 7: Letter1 = "سبعة"
  16. CASE 8: Letter1 = "ثمانية"
  17. CASE 9: Letter1 = "تسعة"
  18. OTHER CASE: Letter1 = ""
  19. END
  20.  
  21. c2 = Val(Middle(c, 11, 1))
  22. SWITCH c2
  23. CASE 1: Letter2 = "عشر"
  24. CASE 2: Letter2 = "عشرون"
  25. CASE 3: Letter2 = "ثلاثون"
  26. CASE 4: Letter2 = "أربعون"
  27. CASE 5: Letter2 = "خمسون"
  28. CASE 6: Letter2 = "ستون"
  29. CASE 7: Letter2 = "سبعون"
  30. CASE 8: Letter2 = "ثمانون"
  31. CASE 9: Letter2 = "تسعون"
  32. OTHER CASE: Letter2 = ""
  33. END
  34. IF Letter1 <> "" AND c2 > 1 THEN Letter2 = Letter1 + " و" + Letter2
  35. IF Letter2 = "" THEN Letter2 = Letter1
  36. IF c1 = 0 AND c2 = 1 THEN Letter2 = Letter2 + "ة"
  37. IF c1 = 1 AND c2 = 1 THEN Letter2 = "إحدى عشرة"
  38. IF c1 = 2 AND c2 = 1 THEN Letter2 = "اثنا عشر"
  39. IF c1 > 2 AND c2 = 1 THEN Letter2 = Letter1 + " " + Letter2
  40.  
  41. c3 = Val(Middle(c, 10, 1))
  42. SWITCH c3
  43. CASE 1: Letter3 = "مائة"
  44. CASE 2: Letter3 = "مائتان"
  45. CASE 3: Letter3 = "ثلاثمائة"
  46. CASE 4: Letter3 = "أربعمائة"
  47. CASE 5: Letter3 = "خمسمائة"
  48. CASE 6: Letter3 = "ستمائة"
  49. CASE 7: Letter3 = "سبعمائة"
  50. CASE 8: Letter3 = "ثمانمائة"
  51. CASE 9: Letter3 = "تسعمائة"
  52. OTHER CASE: Letter3 = ""
  53. END
  54.  
  55. IF Letter3 <> "" AND Letter2 <> "" THEN Letter3 = Letter3 + " و" + Letter2
  56. IF Letter3 = "" THEN Letter3 = Letter2
  57.  
  58. c4 = Val(Middle(c, 7, 3))
  59. SWITCH c4
  60. CASE 1: Letter4 = "ألف"
  61. CASE 2: Letter4 = "ألفان"
  62. CASE 3 TO 10: Letter4 = chiffres_en_lettres_ar(c4) + " آلاف"
  63. CASE > 10 : Letter4 = chiffres_en_lettres_ar(c4) + " ألف"
  64. OTHER CASE: Letter4 = ""
  65. END
  66. IF Letter4 <> "" AND Letter3 <> "" THEN Letter4 = Letter4 + " و" + Letter3
  67. IF Letter4 = "" THEN Letter4 = Letter3
  68.  
  69. c5 = Val(Middle(c, 4, 3))
  70. SWITCH c5
  71. CASE 1: Letter5 = "مليون"
  72. CASE 2: Letter5 = "مليونان"
  73. CASE 3 TO 10: Letter5 = chiffres_en_lettres_ar(c5) + " ملايين"
  74. CASE > 10: Letter5 = chiffres_en_lettres_ar(c5) + " مليون"
  75. OTHER CASE: Letter5 = ""
  76. END
  77. IF Letter5 <> "" AND Letter4 <> "" THEN Letter5 = Letter5 + " و" + Letter4
  78. IF Letter5 = "" THEN Letter5 = Letter4
  79.  
  80. c6 = Val(Middle(c, 1, 3))
  81. SWITCH c6
  82. CASE 1: Letter6 = "مليار"
  83. CASE 2: Letter6 = "ملياران"
  84. CASE 3 TO 10: Letter6 = chiffres_en_lettres_ar(c6) + " ملايير"
  85. CASE > 10: Letter6 = chiffres_en_lettres_ar(c6) + " مليار"
  86. OTHER CASE: Letter6 = ""
  87.  
  88. END
  89. IF Letter6 <> "" AND Letter5 <> "" THEN Letter6 = Letter6 + " و" + Letter5
  90. IF Letter6 = "" THEN Letter6 = Letter5
  91.  
  92. RESULT Letter6
RAW Paste Data