f_replacestr.srf 824 B

1234567891011121314151617181920212223242526272829303132
  1. $PBExportHeader$f_replacestr.srf
  2. global type f_replacestr from function_object
  3. end type
  4. forward prototypes
  5. global function string f_replacestr (string arg_sorstr, string arg_finreplstr, string arg_replobjstr)
  6. end prototypes
  7. global function string f_replacestr (string arg_sorstr, string arg_finreplstr, string arg_replobjstr);//f_replacestr(arg_sorstr,arg_finreplstr,arg_replobjstr)
  8. string obj_str
  9. obj_str=arg_sorstr
  10. long lssit,lssitn,cnt=0
  11. lssit=pos(arg_sorstr,arg_finreplstr)
  12. lssitn=lssit
  13. do while lssit>0 and cnt<1000
  14. obj_str=Replace(obj_str, lssit, len(arg_finreplstr), arg_replobjstr)
  15. if len(arg_replobjstr)>len(arg_finreplstr) then
  16. lssitn=lssitn+len(arg_replobjstr)
  17. else
  18. lssitn=lssitn+len(arg_finreplstr)
  19. end if
  20. lssit=pos(obj_str,arg_finreplstr,lssitn )
  21. cnt++
  22. loop
  23. return obj_str
  24. end function