f_pb_of_globalreplace.srf 679 B

1234567891011121314151617181920212223
  1. $PBExportHeader$f_pb_of_globalreplace.srf
  2. global type f_pb_of_globalreplace from function_object
  3. end type
  4. forward prototypes
  5. global function string f_pb_of_globalreplace (string as_source, string as_old, string as_new)
  6. end prototypes
  7. global function string f_pb_of_globalreplace (string as_source, string as_old, string as_new);long ll_oldlen, ll_newlen, ll_pos
  8. as_source=trim(as_source)
  9. as_old=trim(as_old)
  10. ll_pos = Pos(as_source,as_old)
  11. IF ll_pos > 0 Then
  12. ll_oldlen = Len(as_old)
  13. ll_newlen = Len(as_new)
  14. DO WHILE ll_pos > 0
  15. as_source = Replace(as_source,ll_pos,ll_oldlen,as_new)
  16. ll_pos = Pos(as_source,as_old,ll_pos + ll_newlen)
  17. LOOP
  18. END IF
  19. RETURN as_source
  20. end function