If - Condition
Declaration
<AMIF EXPRESSION="text" USECOMPLEXUI="YES">
Description: Begins a block of steps that are executed conditionally. The If condition along with an Else step are conditional statements that can perform different operations during the course of a task depending on the result of an expression evaluation. 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
Used to perform different activities for different decisions.
Parameters
General
Property |
Type |
Required |
Default |
Markup |
Description |
---|---|---|---|---|---|
Expression |
Text |
Yes |
(Empty) |
|
Indicates a valid BASIC expression. The Simple method allows you to enter a simple expression by entering two values and selecting from the drop-down list of equality operators to be used to compare those values. The Complex method allows entry of more elaborate expressions. NOTE: All literal strings (strings to be taken as themselves) must be enclosed in double quotes (Example: "string literal"). |
Description tab - A custom description can be provided on the Description tab to convey additional information or share special notes about a task step.
Error Causes tab - Specify how this step should behave upon the occurrence of an error. (Refer to Task Builder > Error Causes Tab for details.)
On Error tab - Specify what AWE should do if this step encounters an error as defined on the Error Causes tab. (Refer to Task Builder > On Error Tab for details.)
Examples
The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.
Sample 1: This is a simple task using If condition activity - should result to TRUE.
<AMIF EXPRESSION="1 = 1"> <AMMESSAGEBOX>The result of the expression is TRUE. </AMMESSAGEBOX> <AMELSE /> <AMMESSAGEBOX>The result of the expression is FALSE. </AMMESSAGEBOX> </AMIF>
Sample 2 - This is a more complex task that demonstrates the following:
-
Use of the Input Box activity to ask the user a question and retrieve the answer
-
Use of custom BASIC functions
-
Use of the IF activity
-
Use of Expressions
<AMMESSAGEBOX WINDOWTITLE="Sample Task" BUTTONS="ok_cancel" ICON="information" ONSECONDBUTTONCLICK="stop">This sample task demonstrates the following: 1) Use of the Input Action to ask the user a question and retrieve the answer 2) Use of Custom BASIC Functions 3) Use of the IF action 4) Use of Expressions Remember you can always stop a task in progress by pressing CTRL-ALT-END. Press okay to continue running the task or Cancel to stop now. </AMMESSAGEBOX> <AMVARIABLE NAME="theanswer" DESCRIPTION=""> </AMVARIABLE> <AMSCRIPT>Function SquareNumber(thenum) SquareNumber = thenum * thenum End Function </AMSCRIPT> <AMINPUTBOX RESULTVARIABLE="theanswer">What number would you like to square? </AMINPUTBOX> <AMIF EXPRESSION="IsNumeric(theanswer) = true"> <AMMESSAGEBOX>The number %theanswer% squared is: %SquareNumber(theanswer)% </AMMESSAGEBOX> <AMELSE /> <AMMESSAGEBOX>The text "%theanswer%" is not a valid number. Please re-run and enter a valid number. </AMMESSAGEBOX> </AMIF>