Text File - Find Line

Searches a text file for specific text and returns the zero-based line number where the text was found. Returns -1 if the text cannot be found in the text file.

Action ID:
Action Category:
Action List Syntax:

57
Text File 
<<VARIABLE>>
= TextFile.FindLine (<<FILENAME>>, <<SEARCHTEXT>>, <<STARTATLINENUMBER>>)

Settings

File name:

The full path and filename of the text file to search in.

Search for the line containing the following text:

The string to search for. Note: the search is not case-sensitive.

Start search at line number:

The zero-based line number that you want to start searching from. Note: the line of text at this line number will be included in the search.

Store line number in variable:

The variable that will hold the zero-based line number that represents the line where the search string was found. If the search string cannot be found, -1 will be stored in this variable instead.

Error Codes

Value
(%LastErrorNum%)

Simple Message
(%LastErrorMsg%)

Verbose Message
(%LastErrorDetails%)

0 (OK)

 

 

1

MSG_ERR_FIND_TEXT_LINE

MSG_ERR_FIND_TEXT_LINE
MSG_ERR_FILE_NOT_FOUND
<<FILENAME>>

2

MSG_ERR_FIND_TEXT_LINE

MSG_ERR_FIND_TEXT_LINE
MSG_ERR_OPENING_FILE
<<FILENAME>>

3

MSG_ERR_FIND_TEXT_LINE

MSG_ERR_FIND_TEXT_LINE
MSG_ERR_FILE_TOO_LARGE
<<FILENAME>>

4

MSG_ERR_FIND_TEXT_LINE

MSG_ERR_FIND_TEXT_LINE
MSG_ERR_LINE_OUT_OF_RANGE
<<STARTATLINENUMBER>>

<<FILENAME>>

Examples

Inserting a line in a text file