Pages

Wednesday, November 13, 2013

How to replace string in power builder

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 :

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

No comments:

Post a Comment

Don't Forget To Join Our Community
×
Widget