CHANGE Call

CALL CHANGE (matrix, old, new <, numchange> ) ;

The CHANGE subroutine searches for and replaces text in a character matrix. The arguments to the CHANGE call are as follows:

matrix

is a character matrix.

old

is the string to be changed.

new

is the string to replace the old string.

numchange

is the number of times to make the change.

The CHANGE subroutine changes the first numchange occurrences of the substring old in each element of the character array matrix to the form new. If numchange is not specified, the routine defaults to 1. If numchange is 0, the routine changes all occurrences of old. If no occurrences are found, the matrix is not changed.

For example, consider the following statements:

a = "It was a dark and stormy night.";
call change(a, "night", "day");
print a;

The result of these statements is shown in Figure 23.58.

Figure 23.58: New String

a
It was a dark and stormy day.


In the old operand, the following characters are reserved:

 

% $ [ ] { } < > $-$ ? * # @ ’ ‘(backquote) ^