Find Text Action Icon

Find Text

Declaration

<AMFINDTEXT TEXT="text(target text)" FIND="text(text to find)" RESULTVARIABLE="text" USERE="YES/NO" USECASE="YES/NO" FOUNDTEXTVARIABLE="text" TOTALMATCHESVARIABLE="number" />

See Also

Convert Case | Find Text | Format Date/Time | Get Subtext | Insert Text | Pad Text | Replace Text | Trim Text

Description

Finds each or every occurrence of a text pattern and places the result into a variable. Regular expressions may be used for added power and flexibility.

Practical Usage

Mainly used to locate a word or phrase inside of a larger piece of text.

Parameters

General Properties

Property

Type

Required

Default

Markup

Description

Text

Text

Yes

(Empty)

 

TEXT="My name is Joe"

The target text to be searched. As with every text parameter, if the data you wish to enter is contained in a variable, simply enter the variable name surrounded by percentage signs to resolve it to it's contents at runtime (i.e. %VarName%).

Find

Text

Yes

(Empty)

FIND="name"

The text to search for.

Case Sensitive

Yes/No

No

No

USECASE="YES"

Specifies whether the search performed should be case sensitive. If set to YES, the search is case sensitive. This parameter is set to NO by default.

Regular Expression

Yes/No

No

No

USERE="YES"

Specifies whether the Find parameter is a regular expression. If set to NO (default), the Find parameter contains literal text. If set to YES, the Find parameter contains a regular expression.

Populate variable with first index

Text

Yes

(Empty)

RESULTVARIABLE="varname"

The variable to receive the first position of the text, if found.

Advanced Properties

Property

Type

Required

Default

Markup

Description

Starting at the following instance

Number

No

1

 

INDEX="2"

Indicates that the target text should be searched starting at the following instance.  

Total Find Count into Variable

Text

No

(Empty)

TOTALMATCHESVARIABLE="varname"

The variable to receive the total instances found.

Populate Variable with found text

Text

No

(Empty)

FOUNDTEXTVARIABLE="varname"

The variable to receive the text that was found. This parameter is useful if a regular expression is used to find text.

 

Description Properties

The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.

More on setting custom step description

Error Causes Properties

The Error Causes tab properties lets you instruct a task step to react only to specific errors or ignore certain errors that should cause it to fail.

More on Error Causes properties

On Error Properties

The On Error tab properties lets you determine what the task should do if a particular step encounters an error as defined in the Error Causes properties.

More about On Error properties

Additional Notes

Expressions, Variables & Functions

A percent sign is used as a special character in AutoMate to indicate the beginning and end of an expression. This allows variables, functions and other expressions to be entered in any text parameter of a task's properties. For example: %1+1% inside a task will resolve to 2 at runtime. A more elaborate example is %FileDateTime(myFile)% which results to the date/time of myFile. To help construct expressions, you can open Expression Builder by clicking the Insert Expression (%) button or by pressing F2.

More on expressions

More on variables

More on functions

More on extended functions
More on the expression builder

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

 

Description: This sample task searches for the word 'occurrence' from the specified body of text. A message box then displays the position in which the first instance of this text appeared as well as the total number of times it appeared.

 

<AMVARIABLE NAME="indexVar"></AMVARIABLE>

<AMVARIABLE NAME="totalInstances"></AMVARIABLE>

<AMFINDTEXT TEXT="This action finds each or every occurrence of a text pattern and places the result of each occurrence into a variable." FIND="occurrence" RESULTVARIABLE="indexVar" TOTALMATCHESVARIABLE="totalInstances" />

<AMMESSAGEBOX>The word 'occurrence' was found at position %indexVar%.&#xD;&#xA;The total number of times this word appeared was %totalInstances% times.</AMMESSAGEBOX>

 

↑ [Top of Page]