uo_string_helper.sru 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. $PBExportHeader$uo_string_helper.sru
  2. forward
  3. global type uo_string_helper from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_string_helper from nonvisualobject autoinstantiate
  7. end type
  8. type variables
  9. string ins_string
  10. end variables
  11. forward prototypes
  12. public subroutine uf_split (string arg_spliter, ref string arg_rslt[])
  13. public subroutine uf_replace (string arg_parm, string arg_value)
  14. public function string uf_getfunname (string arg_funname)
  15. end prototypes
  16. public subroutine uf_split (string arg_spliter, ref string arg_rslt[]);long ll_start = 1
  17. long ll_pos
  18. long ll_cnt = 0
  19. string ls_rslt[]
  20. ll_pos = pos(ins_string, arg_spliter, ll_start)
  21. do while ll_pos > 0
  22. ll_cnt++
  23. ls_rslt[ll_cnt] = mid(ins_string, ll_start, ll_pos - ll_start)
  24. ll_start = ll_pos + len(arg_spliter)
  25. ll_pos = pos(ins_string, arg_spliter, ll_start)
  26. loop
  27. ll_cnt ++
  28. ls_rslt[ll_cnt] = mid(ins_string, ll_start)
  29. arg_rslt = ls_rslt
  30. end subroutine
  31. public subroutine uf_replace (string arg_parm, string arg_value);long ll_pos = 1, ll_find
  32. ll_find = pos(ins_string, arg_parm, ll_pos)
  33. do while ll_find > 0
  34. ins_string = Replace(ins_string, ll_find, len(arg_parm), arg_value)
  35. ll_pos = ll_find + len(arg_value)
  36. ll_find = pos(ins_string, arg_parm, ll_pos)
  37. loop
  38. end subroutine
  39. public function string uf_getfunname (string arg_funname);long ll_pos
  40. ll_pos = pos(ins_string, arg_funname)
  41. if ll_pos <= 0 then
  42. return arg_funname
  43. end if
  44. ll_pos = pos(ins_string, arg_funname, ll_pos + len(arg_funname))
  45. if ll_pos <= 0 then
  46. return arg_funname
  47. end if
  48. long ll_p2
  49. ll_p2 = pos(ins_string, ')', ll_pos)
  50. if ll_p2 <= 0 then
  51. return arg_funname
  52. end if
  53. return mid(ins_string, ll_pos, ll_p2 - ll_pos + 1)
  54. end function
  55. on uo_string_helper.create
  56. call super::create
  57. TriggerEvent( this, "constructor" )
  58. end on
  59. on uo_string_helper.destroy
  60. TriggerEvent( this, "destructor" )
  61. call super::destroy
  62. end on