f_char_to_dec_workprice.srf 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. $PBExportHeader$f_char_to_dec_workprice.srf
  2. global type f_char_to_dec_workprice from function_object
  3. end type
  4. forward prototypes
  5. global function decimal f_char_to_dec_workprice (string arg_computstr, integer arg_mxbt)
  6. end prototypes
  7. global function decimal f_char_to_dec_workprice (string arg_computstr, integer arg_mxbt);Decimal ld_dec_arr[],ld_dec_return
  8. Long ll_cnt
  9. Long ll_len,ll_i
  10. String ls_dec_tmp,ls_char_tmp
  11. Int ll_asc
  12. ld_dec_return = 0
  13. ll_len = lenA(arg_computstr)
  14. For ll_i = 1 To ll_len
  15. ls_char_tmp = midA(arg_computstr,ll_i,1)
  16. ll_asc = Asc(ls_char_tmp)
  17. If ll_asc >= 48 And ll_asc <= 57 Then
  18. //0~9
  19. ls_dec_tmp = ls_dec_tmp + ls_char_tmp
  20. If ll_i < ll_len Then
  21. Continue
  22. End If
  23. ElseIf ll_asc = 46 Then
  24. //asc 46 = '.'
  25. If Trim(ls_dec_tmp) = '' Then
  26. If ll_i < ll_len Then
  27. Continue
  28. End If
  29. Else
  30. ls_dec_tmp = ls_dec_tmp + ls_char_tmp
  31. If ll_i < ll_len Then
  32. Continue
  33. End If
  34. End If
  35. End If
  36. If Trim(ls_dec_tmp) <> '' Then
  37. If Mid(ls_dec_tmp,Len(ls_dec_tmp),1) = '.' Then
  38. ls_dec_tmp = Mid(ls_dec_tmp,1,Len(ls_dec_tmp) - 1)
  39. End If
  40. ll_cnt++
  41. ld_dec_arr[ll_cnt] = Dec(ls_dec_tmp)
  42. ls_dec_tmp = ''
  43. End If
  44. Next
  45. For ll_i = 1 To ll_cnt
  46. If ll_i = arg_mxbt Then
  47. ld_dec_return = ld_dec_arr[ll_i]
  48. End If
  49. Next
  50. Return ld_dec_return
  51. end function