#*********************************************************************
# replicate_str(inout s, in sub1, in sub2)
#*********************************************************************
# Description :Replaces a certain sign in a string with another sign
#_____________________________________________________________________
#
# Example: The name of variable 's' is filled with 'ill'.
# function call: repl_str(name, "l", "n");
# After executing this function the variable name is
# filled with 'inn'
#*********************************************************************
public function repl_str(inout s, in sub1, in sub2)
{
	auto ptr;
	auto src = s;
	auto temp = "!@#";
	auto sub1_len = length(sub1);
	auto temp_len = length(temp);

	while ( ptr = index(src, sub1) )
	src = substr(src, 1, ptr - 1) & temp & substr(src, ptr + sub1_len);

	while (ptr = index(src, temp))
	src = substr(src, 1, ptr - 1) & sub2 & substr(src, ptr + temp_len);

	s = src;
}

String = "This is text 1234-5678 with a minus sign in it.";
FindChar = "-";
ReplaceChar = "\-";

set_window ("Untitled - Notepad", 1);
win_activate ("Untitled - Notepad");
edit_set_insert_pos ("Edit", 0, 0);

type ( "Before inserting the back slash character: <kReturn>" & String );
type ( "<kReturn><kReturn>" );

rc1 = repl_str ( String, FindChar, ReplaceChar );

type ( "After inserting the back slash character: <kReturn>" & String );
type ( String );
type ( "<kReturn><kReturn>" );

printf ( String );



