f_convert.srf 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. $PBExportHeader$f_convert.srf
  2. $PBExportComments$金额大写--函数
  3. global type f_convert from function_object
  4. end type
  5. forward prototypes
  6. global function string f_convert (decimal ad_number)
  7. end prototypes
  8. global function string f_convert (decimal ad_number);string ls_hz1[15],ls_hz2[10],ls_return,ls_temp,ls_argument
  9. int li_1,li_len
  10. boolean lb_first_zero
  11. ls_hz1[1]="分"
  12. ls_hz1[2]="角"
  13. ls_hz1[3]=""
  14. ls_hz1[4]="元"
  15. ls_hz1[5]="拾"
  16. ls_hz1[6]="佰"
  17. ls_hz1[7]="仟"
  18. ls_hz1[8]="万"
  19. ls_hz1[9]="拾"
  20. ls_hz1[10]="佰"
  21. ls_hz1[11]="仟"
  22. ls_hz1[12]="亿"
  23. ls_hz1[13]="拾"
  24. ls_hz1[14]="佰"
  25. ls_hz1[15]="仟"
  26. ls_hz2[1]="壹"
  27. ls_hz2[2]="贰"
  28. ls_hz2[3]="叁"
  29. ls_hz2[4]="肆"
  30. ls_hz2[5]="伍"
  31. ls_hz2[6]="陆"
  32. ls_hz2[7]="柒"
  33. ls_hz2[8]="捌"
  34. ls_hz2[9]="玖"
  35. ls_hz2[10]="零"
  36. if ad_number=0 then return '零元整'
  37. ls_argument=string(ad_number,"0.00")
  38. if len(ls_argument)>15 then return ''// 数值不能大于千亿
  39. if right(ls_argument,1)='0' then ls_return='整'
  40. do while true
  41. li_1 += 1
  42. li_len=len(ls_argument)
  43. ls_temp=right(ls_argument,1)
  44. ls_argument=left(ls_argument,li_len - 1)
  45. if ls_temp='' or isnull(ls_temp) then
  46. exit
  47. end if
  48. if ls_temp='.' then
  49. continue
  50. end if
  51. if ls_temp='-' then
  52. ls_return='负'+ls_return
  53. continue
  54. end if
  55. if ls_temp<>'0' then
  56. ls_return=ls_hz2[integer(ls_temp)]+ls_hz1[ li_1 ]+ls_return
  57. lb_first_zero=true
  58. else
  59. if lb_first_zero then
  60. if (li_1<>4 and li_1<>2) or dec(ls_argument)<>0 then
  61. ls_return='零'+ls_return
  62. end if
  63. lb_first_zero=false
  64. end if
  65. if li_1=12 or li_1=8 then
  66. if right(ls_argument,3)<>'000' then ls_return=ls_hz1[li_1]+ls_return
  67. end if
  68. if li_1=4 then
  69. if dec(ls_argument)<>0 then ls_return=ls_hz1[li_1]+ls_return
  70. end if
  71. end if
  72. loop
  73. return ls_return
  74. end function