If Text Contains Action

Declaration

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

See Also

     If Text Contains Action-Setting Properties, Else Action, End If Action, Loop List Action, The BASIC Language All Groups

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

To check the contents of a piece of text and take conditional action depending on whether it is found.

Parameters

General Tab

If

Text, Optional Default: contain)
MARKUP: 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:

Target text

Text, Required
MARKUP: TEXT="The rabbit ran away"

Specifies the text to search.

Text to look for

Text, Required
MARKUP: SUBSTRING="rabbit"

Specifies the text to search for inside the target text.

Case Sensitive

Yes/No, Optional (default: No)
MARKUP: USECASE="YES"

Specifies whether the search performed should be case sensitive.  

Regular Expression

Yes/No, Optional (default: No)
MARKUP: USERE="YES"

Specifies whether the FIND parameter is a regular expression. If the option is no, the Find parameter contains literal text, if the option is yes, the find parameter contains a regular expression.

Place matched text into variable

Text [variable name], Optional
MARKUP: 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 [variable name], Optional
MARKUP: INDEXVAR="varname"

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

Notes

Custom Description

This action includes the Description tab for entering a custom step description.

More on setting custom step description

Standard Error Handling Options

This action also includes the standard Error Causes and On Error failure handling options/tabs.

More on Error Handling Options

Variables and Expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by pressing F2.

More on variables
More on expressions

More on the expression builder

Examples

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

<AMIFCONTAINS TEXT="The rabbit ran away" SUBSTRING="ran">
<AMMESSAGEBOX>the word 'ran' was found inside the search text</AMMESSAGEBOX>
</AMIF> 

.