4D Write v14

WR Replace

Home

 
4D Write v14
WR Replace

WR Replace 


 

WR Replace ( area ; searchedFor ; replaceWith ; wholeWord ; upperCase ; replaceAll ; wrap ) -> Function result 
Parameter Type   Description
area  Longint in 4D Write area
searchedFor  String in Character string to search for
replaceWith  String in Replacement character string
wholeWord  Integer in 0=partial match 1=whole word
upperCase  Integer in 0=ignore uppercase 1=case sensitive
replaceAll  Integer in 0=replace next 1=replace all
wrap  Integer in 0=search from the selection 1=search the whole document
Function result  Longint in Number of occurrences replaced

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:

Constant Type Value Comment
wr partial match Longint 0 The character string can either be a whole word or part of a longer word
wr whole word Longint 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:

Constant Type Value Comment
wr ignore uppercase Longint 0 The search is not case sensitive and will find both “Hello”, “hello” and “HELLO“... if you search for “HELLO”
wr case sensitive Longint 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:

Constant Type Value Comment
wr replace next Longint 0 Only the next occurrence of the word will be replaced
wr replace all Longint 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:

Constant Type Value Comment
wr after insertion point Longint 0 The search begins at the insertion point and continues to the end of the document.
wr whole document Longint 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

 
PROPERTIES 

Product: 4D Write
Theme: WR Text Manipulation
Number: 89453

 
HISTORY 

Created: 4D Write 6.5

 
SEE ALSO 

WR Find
WR SELECT

 
ARTICLE USAGE

4D Write Language ( 4D Write v11.6)
4D Write Language ( 4D Write v12)
4D Write Language ( 4D Write v14)
4D Write Language ( 4D v13)
4D Write Language ( 4D Write v14 R2)
4D Write Language ( 4D Write v14 R3)
4D Write Language ( 4D Write v14 R4)