version 6.5
WR Replace (area; searchedFor; replaceWith; wholeWord; upperCase; replaceAll; wrap) Longint
| Parameter | Type | Description | |
| area | Longint | 4D Write area | |
| searchedFor | String | Character string to search for | |
| replaceWith | String | Replacement character string | |
| wholeWord | Integer | Search for whole word | |
| upperCase | Integer | Take uppercase characters into account | |
| replaceAll | Integer | 0=replace next | |
| 1=replace all | |||
| wrap | Integer | 0=search from the selection | |
| 1=search the whole document | |||
| Function result | Longint | Number of occurrences replaced |
Description
The WR Replace command allows you to emulate the Replace command menu of the Edit menu.
If wholeWord equals 1, only whole words will be searched for. For a string to be found using this option, it must occur between punctuation characters (space, comma and so on).
If upperCase equals 1, the search will look for a character string whose case matches the case of the original string .
If replaceAll equals 1, each occurrence of the character string will be replaced. If replaceAll does not equal 1, only the first occurrence will be replaced.
wrap allows you to define whether the search applies to the entire document. If wrap equals 1, the search will be performed on the entire document, otherwise the search will be performed from the position of the selection to the end of the document.
WR Replace returns the number of occurrences replaced.
Example
You want to remove all unnecessary double spaces in your document:
`Assigning a variable that contains double space characters ToFind:=" " `While occurrences are found While(WR Find(Area;ToFind;0;0;1)=1) `Replacing double space by a single one $n:=WR Replace(Area;ToFind;" ";0;0;1;0) End while
See also