If Text Contains Action Icon

If Text Contains

Declaration

<AMIFCONTAINS ACTION="text [options]" TEXT="text" SUBSTRING="text" USERE="YES" USECASE="YES" FOUNDTEXTVARIABLE="text [variable]" INDEXVAR="text [variable]">

See Also

Else | End If | End Select/Case | Goto | If | If Compare Files | If File Exists | If Folder Exists | If Last Step | If Pixel Exists | If Process Running | If Text Contains | If Windows Exists | Label | Select/Case

Description

Executes the steps immediately following this step if the specified text is (or is not) contained within the target text. Otherwise, step execution follows the next Else step, or End If step.

Practical Usage

Commonly used to check the contents of a piece of text and perform conditional actions depending on whether it is found.

Parameters

General Properties

Property

Type

Required

Default

Markup

Description

If

Text (Options)

Yes

Text Contains

ACTION="not_contain"

Specifies whether the condition should check for the characters to be contained or not contained within the text. The available options are:

  • Text contains: The IF block will be executed if the characters are contained in the text.

  • Text does not contain: The IF block will be executed if the characters are not contained in the text.

Target text

 

Text

Yes

(Empty)

TEXT="The target text"

The text to search from. As with every text parameter, if the data you wish to write 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%).

Text to look for

 

Text

Yes

(Empty)

SUBSTRING="target"

The text to search for inside the target text. As with every text parameter, if the data you wish to write 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%).

Case Sensitive

Yes/No

No

No

USECASE="YES"

Specifies whether the search performed should be case sensitive. If set to YES, case sensitivity is turned on. If set to NO (default) case sensitivity is turned off.

Regular Expression

Yes/No

No

No

USERE="YES"

If set to YES, specifies whether the data entered in the Text to look for parameter is a regular expression. If set to NO (default), Text to look for parameter contains literal text.

Advanced Properties

Property

Type

Required

Default

Markup

Description

Place matched text into variable

Text

No

(Empty)

FOUNDTEXTVARIABLE="varname"

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

Index of matched text into variable

Text

No

(Empty)

INDEXVAR="varname"

Specifies the variable to receive the index position of the text that was found.

 

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: If the target text contains the word "ran" a message box will be displayed.

 

<AMVARIABLE NAME="theTargetText">The rabbit ran away.</AMVARIABLE>

<AMIF TEXT="%theTargetText%" SUBSTRING="ran">

     <AMSHOWDIALOG MESSAGE="The variable named theTargetText contained the word &quot;ran&quot; " />

</AMIF>

 

↑ [Top of Page]