If - Contains Text
Declaration
<AMIF ACTIVITY="contains_text" TEXT="text" SUBSTRING="text" ACTION="text (options)" USERE="YES/NO" USECASE="YES/NO" FOUNDTEXTVARIABLE="text" INDEXVARIABLE="text">
Description: Determines if the text to look for is contained within the target text and returns TRUE or FALSE depending on the outcome. Optionally, this activity can determine whether the target text starts with or ends with the text to look for. If the result evaluates to TRUE, the task will execute the block of steps immediately following this step up until an End if step is encountered. If the result evaluates to FALSE, the block will be skipped and execution will proceed directly after the End if step (or if an Else step is encountered, the task will execute that block of steps instead, up until an End if step is encountered).
Practical Usage
Commonly used to check the contents of a piece of text and perform conditional actions depending on whether it is found.
General Parameters
Property |
Type |
Required |
Default |
Markup |
Description |
---|---|---|---|---|---|
If text |
Text (Options) |
Yes |
Contains |
|
Specifies the condition should check for the characters to be contained or not contained within the text. The available options are:
|
Target text |
Text |
Yes |
(Empty) |
TEXT="TheTargetText" |
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 (e.g., %VarName%). |
Text to look for |
Text |
Yes |
(Empty) |
SUBSTRING="TextToFind" |
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 (e.g., %VarName%). |
Cases 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, the Text to look for parameter contains a regular expression. If set to NO (default), the Text to look for parameter contains literal text. |
Advanced Parameters
Property |
Type |
Required |
Default |
Markup |
Description |
---|---|---|---|---|---|
Index of matched text into variable |
Text |
No |
(Empty) |
INDEXVAR="var2" |
The name of an existing variable to receive the index position of the text that was found. |
Place matched text into variable |
Text |
No |
(Empty) |
FOUNDTEXTVARIABLE="var1" |
The name of an existing variable to receive the text that was found. This parameter is useful if a regular expression was entered in the Text to look for parameter. |
Example
The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.
Description: A simple task that determines if the target text contains the word "ran." If so, 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 'ran'" /> </AMIF>