String-Commands * TXT-Command

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > TXT. Text-File Engine > Find- and Replace Operations >

String-Commands * TXT-Command

TXT.Replace_in_Text

Previous Top Next


MiniRobotLanguage (MRL)

 

TXT.rit

TXT.Replace_in_Text
Search a Text in the TXT.-internal Buffer and replace it with a given other sequence, using an Equalcase-Search Algo.

 

 

 

Intention

 

This command is used to replace all occurrences of a Search-String in the TXT.-Buffer with another String.

It uses an Equalcase-Algorhytm so it will search "equal-case" but the replace will be done with the proper case.

 

'Replace all "e" with "ef" in internal TXT.-Buffer

VAR.$$LAB=e

VAR.$$LAC=ef

TXT.rit|$$LAB|$$LAC

ENR.

 

 

 

VAR.$$LAA=?path\..\Pics\Test.txt

TXT.ltf|$$LAA|$$RES

' This example shows all features of TXT.rit

' We are running in 2 times so its clear that due to the Equalcase-Replace,

' also the "EE" will be treated as "ee" and replaced.

TXT.rit|e|EE|520

TXT.rit|e|EE|520

' You can also see that the replace starts a Position 520, as specified.

' So the start of the text is unchanged.

 

TXT_RIT

 

 

Syntax

 

 

TXT.rit|$$SEA|$$REP[|$$STA]

TXT.Replace_in_Text|P1|P2[|P3]

 

 

Parameter Explanation

 

P1 - (Input) Variable with String to search for.

P2 - (Input) Variable with the String that shall replace the String in P1.

P3 - (optional, numeric) Variable with a Byte-Position in  the TXT.-Buffer, if given the replace will start at that Position.
 If omitted the complete Text is been searched and replaced.

 

 

Example

 

'*****************************************************

' EXAMPLE 1:

'*****************************************************

VAR.$$LAA=?path\..\Pics\Test.txt

TXT.ltf|$$LAA|$$RES

VAN.$$STA=100

'Replace all "e" with "ef" in internal TXT.-Buffer starting from Byte-Position 100

VAR.$$OLD=e

VAR.$$NEW=ef

TXT.rit|$$OLD|$$NEW|$$STA

ENR.

 

 

Remarks

 

Will replace ALL occurences of the Search-String. Uses an Equalcase-Algo so the search-string will be found whether in lower- or in Upper-case..

 

 

Limitations:

 

-

 

 

See also:

 

 

!TXT. - Text File Engine

TXT.Load Textfile

TXT.Clear

TXT.From_Var

OPT. - Optional Settings

TXT.Replace_in_Text

TXT.Replace

TXT.Replace_in_Line

  Push_Intern

  Pop_Intern  

  Push_Keep

  Pop_Keep

  Clear_Intern

  TXT.Load Textfile

  TXT.Clear  

  TXT.To_Var

  TXT.From_Var

  TXT.To_Var_and_Clear

  TXT.Get_Filename

  TXT.Get_Lenght