WR Replace

4D - Documentation   Français   English   German   4D Write, Command Theme List   4D Write, Command Alphabetical List   4D Write, Constant Theme List   Back   Previous   Next

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
wholeWordIntegerSearch for whole word
upperCaseIntegerTake uppercase characters into account
replaceAllInteger0=replace next
1=replace all
wrapInteger0=search from the selection
1=search the whole document
Function resultLongintNumber 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

WR SELECT.


4D - Documentation   Français   English   German   4D Write, Command Theme List   4D Write, Command Alphabetical List   4D Write, Constant Theme List   Back   Previous   Next