REPLINS$ returns a modified document


Syntax

REPLINS$(Document$, Search%, InsRepDoc$, Pos%, [Mode%=0,1])


Arguments

Remarks

  1. REPLINS$ returns a document on which Remove and Insert operations are performed.
  2. When Search% = "NullString", sentences will be inserted based on the position defined by Pos% (see examples)
  3. Please look at the MARK$() function to replace parameters in a data set.
  4. The use of REPLINS$() in combination with other string/text manipulation functions  will provide flexible means to process text data.

Examples

The document we use for all the examples below is: 

Document$ = "Things fall apart; the centre cannot hold; 
                     The blood tide is lost everywhere"



Replace lost with loosed:

 Pos% = 0

 Search% = "lost"

 InsRepDoc$ = "lost"

So: 

Document1$ = REPLINS$(Document$, "lost", "loosed", 0)



returns:

"Things fall apart; the centre cannot hold; 
The blood tide is loosed everywhere"




Add , and immediately behind loosed:

Pos% = 1

Search% = "loosed"

InsRepDoc$ = ", and"

 So: 

Document2$ = REPLINS$(Document1$, "loosed", ", and", 1)

returns:

"Things fall apart; the centre cannot hold; 
The blood tide is loosed, and everywhere"


Add -dimmed immediately before  tide, including the space, so make sure to define " tide":

Pos% = -1

Search% = " tide"

InsRepDoc$ = ", -dimmed"

So: 

Document3$ = REPLINS$(Document2$, " tide", "-dimmed", -1)

returns:

"Things fall apart; the centre cannot hold; 
The blood-dimmed tide is loosed, and everywhere"

 

Add Mere anarchy is loosed upon the world after the first sentence:

Pos% = 1

Search% = "NullString"

InsRepDoc$ = "Mere anarchy is loosed upon the world"

So: 

Document4$ = REPLINS$(Document3$, "NullString", "Mere anarchy is loosed upon the world", 1)

returns:

"Things fall apart; the centre cannot hold; 
Mere anarchy is loosed upon the world 
The blood-dimmed tide is loosed, and everywhere"


Add Turning and turning in the widening gyre two lines before the first sentence:

Pos% = -2

Search% = "NullString"

InsRepDoc$ = "Turning and turning in the widening gyre" 

So: 

Document5$ = REPLINS$(Document4$, "NullString", "Turning and turning in the widening gyre", -2)

returns:

"Turning and turning in the widening gyre 

Things fall apart; the centre cannot hold; 
Mere anarchy is loosed upon the world 
The blood-dimmed tide is loosed, and everywhere"


Add The falcon cannot hear the falconer; one line after the word widening:

 Pos% = 2: the insert will be done (Pos%-1) lines after the line with Search%

Search% = "widening"

InsRepDoc$ = "The falcon cannot hear the falconer;"

So: 

Document6$ = REPLINS$(Document5$, "widening", "The falcon cannot hear the falconer;", 2)

returns:

"Turning and turning in the widening gyre 
The falcon cannot hear the falconer; 
Things fall apart; the centre cannot hold; 
Mere anarchy is loosed upon the world 
The blood-dimmed tide is loosed, and everywhere"


Add The Second Coming two lines before the word widening:

Pos% = -2: the insert will be done -2 lines before the line with Search%

Search% = "widening"

InsRepDoc$ = "The Second Coming"  

So: 

Document7$ = REPLINS$(Document6$, "widening", "The Second Coming", -2)

returns:

"The Second Coming 

Turning and turning in the widening gyre 
The falcon cannot hear the falconer; 
Things fall apart; the centre cannot hold; 
Mere anarchy is loosed upon the world 
The blood-dimmed tide is loosed, and everywhere"

 

 

Quick links: Functions overview | Attribute overview | Constants overview | Dimensions overview