<< Click to Display Table of Contents >> Navigation: 3. Script Language > TXT. Text-File Engine > Find- and Replace Operations > String-Commands * TXT-Command |
MiniRobotLanguage (MRL)
TXT.fit
TXT.Find_Text
Search a Text in the TXT.-internal Buffer and return various Information where it was found.
Can also do a reverse search, see P2.
Intention
This is the extended search command. it will return detailled results.
This command is used to get the Byte-Positions of Start- and End of a specified Line, from the Text that is in the Internal TXT-Buffer into Variables.
Unlike TXT.glp, it works from a Byte-Position. So you say "Byte 42" and the command will return the start- and End-Byte of the line,
that contains Byte 43. Variable P2 will contain the Start-Byte of the Line. Variable P3 will contain the Last-Byte of the Line before and excluding the $crlf$.
This Command can be used to work on a Byte-Base through a file without accessing the file on the harddrive.
$$SEA=SWP.
$$LAB=0
TXT.fit|$$SEA|0|$$RES|$$LAB
DMP.6
MBX.Was found at Byte-Pos: $$RES$crlf$ Byte-Position in the Line:$$LAB
ENR.
TXT.fit|$$SEA
So you get following Information:
TOS: End-Byte of Line with the found text
TOS+1: Start-Byte of Line with the found text
TOS+2: Linenumber where the Text was found, or "0" if not found
TOS+3: Byte-position of the found-Text in the Line (Text starts here at character 3 in the Line 13)
TOS+4: Byte-Position of the found Text in the whole-text
Syntax
TXT.fit|P1[|P2][|P3][|P4][|P5][|P6][|P7]
TXT.Find_Text|P1[|P2][|P3][|P4][|P5][|P6][|P7]
Parameter Explanation
P1 - (Input) Variable with String to search for.
P2 - (numeric or string) Starting-Position and Flags "B" (Byte) and "L" (Line). If omitted "L" is taken as default.
If "R" is specified this will activate "Reverse Search".
Variable will contain a number or 0 can also contain "L" or "B" or "R",
This the Starting-Line Number for the search. The search will start at the first byte of the specified Line.
If this contains a letter "B" then the number will be taken as a Byte-Position, where to start the search.
If this contains a letter "R" then a reverse search is performed.
If the number is a Byte-Position (using "B"), it will be counted counted from the end of the file and it will perform a Reverse search,
from the end of the file towards the start.
If the number is a Linenumber, the linenumber will also be reversed, eg. the last line is Line 1.
If this is 0 or 1, the complete loaded Textfile will be searched.
If no letter is given, the default way to interpret this number is "L" (as Linenumber).
P3 - (Output) Variable will contain the Byte-Position of the Search String in the whole Text.If omitted, the result is placed on TOS.
If this result is "0" nothing was found.
P4 - (Output) Variable will contain the Byte-Position of the Search String in the Line where it was found.
If omitted, the result is placed on TOS. If this result is "0" nothing was found.
P5 - (Output) Variable will contain the Line-Number of the Line that contains the Search String or 0 if nothing was found.
If omitted, the result is placed on TOS.
P6 - (Output) Variable will contain the Byte-Position of the fist-Byte of the Line where the Search string was found.
If omitted, the result is placed on TOS.
P7 - (Output) Variable will contain the Byte-Position of the Last-Byte of the Line where the Search string was found.
Does not include the $crlf$ at the End of the Line.If omitted, the result is placed on TOS.
Example
'*****************************************************
' EXAMPLE 1:
'*****************************************************
VAR.$$LAA=?path\..\Pics\Test.txt
TXT.ltf|$$LAA|$$RES
VAN.$$LAC=0
$$SEA=SWP.
$$LAB=0
TXT.fit|$$SEA|0|$$RES|$$LAB
ENR.
Remarks
-
Limitations:
-
See also:
• IEF. / NEF. - If - exist - File