In this post we will discuss about how to replace string in power builder using our custom routine. This routine works generically for any string.
For example, if old_str = "red" and new_str = "green", all occurrences of "red" inside of mystring will be replaced with "green".
Here is the script :
For example, if old_str = "red" and new_str = "green", all occurrences of "red" inside of mystring will be replaced with "green".
Here is the script :
long ll_StartPos = 1
ll_StartPos = Pos(arg_str, arg_search, ll_StartPos)
DO WHILE ll_StartPos > 0
arg_str = Replace(arg_str, ll_StartPos, Len(arg_search), arg_replace)
ll_StartPos = Pos(arg_str, arg_search, ll_StartPos + Len(arg_search))
LOOP
return arg_str
ll_StartPos = Pos(arg_str, arg_search, ll_StartPos)
DO WHILE ll_StartPos > 0
arg_str = Replace(arg_str, ll_StartPos, Len(arg_search), arg_replace)
ll_StartPos = Pos(arg_str, arg_search, ll_StartPos + Len(arg_search))
LOOP
return arg_str
No comments:
Post a Comment