Command WR Replace

4D Write

WR Replace

version 6.5


WR Replace (area; searchedFor; replaceWith; wholeWord; upperCase; replaceAll; wrap) Longint

ParameterTypeDescription
areaLongint4D Write area
searchedForStringCharacter string to search for
replaceWithStringReplacement character string
wholeWordInteger0=partial match
1=whole word
upperCaseInteger0=ignore uppercase
1=case sensitive
replaceAllInteger0=replace next
1=replace all
wrapInteger0=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.

In the wholeWord parameter, you can pass one of the following constants, found in the WR Parameters theme:

Constants (value)Description
wr partial match (0)The character string can either be a whole word or part of a longer
word
wr whole word (1)To be found, the word must occur between separator characters
(spaces, punctuation marks, etc.)

In the upperCase parameter, you can pass one of the following constants, found in the WR Parameters theme:

Constants (value)Description
wr ignore uppercase (0)The search is not case sensitive and will find both "Hello", "hello" and
"HELLO"... if you search for "HELLO"
wr case sensitive (1)The search is case sensitive and will not find "Hello" if you are
searching for "HELLO"

In the replaceAll parameter, you can pass one of the following constants, found in the WR Parameters theme:

Constants (value)Description
wr replace next (0)Only the next occurrence of the word will be replaced
wr replace all (1)All the occurrences of the word will be replaced

In the wrap parameter, you can pass one of the following constants, found in the WR Parameters theme:

Constants (value)Description
wr after insertion point (0)The search begins at the insertion point and continues to the end of the
document.
wr whole document (1)The search begins at the insertion point, continues to the end and then
starts again at the beginning of the document until it again reaches the
insertion point.

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;wr partial match;wr ignore uppercase;wr whole document)=1)
         `Replacing double space by a single one 
      $n:=WR Replace(Area;ToFind;" ";wr partial match;wr ignore uppercase;wr replace all;wr whole  document)
   End while 

See Also

WR Find, WR SELECT.