Syntax.CreateCondition Method

Applies to TestComplete 15.68, last modified on October 16, 2024

Description

This method creates and returns a syntax element that corresponds to a comparison or logical operation. For example:

x > y

or

x and y

To specify the comparison or logical operator to be used (>, <, >=, <=, logical AND, logical OR, etc.), use the OperatorType property of the obtained syntax element. To specify the expressions to be used on the left and right sides of the operator, use the element’s Left and Right properties.

Declaration

Syntax.CreateCondition()

Result A ConditionSyntax object

Applies To

The method is applied to the following object:

Result Value

A ConditionSyntax object that corresponds to a comparison or logical operation.

Example

The following example generates the code that checks whether the Answer variable is equal to 42, and displays this code in a message box.

JScript

function ShowConditionStatement()
{
    var oVarName = Syntax.CreateInvoke();
    oVarName.InvokeName = "Answer";
    oVarName.IsProperty = true;

    var oCondition = Syntax.CreateCondition();
    oCondition.OperatorType = oCondition.otEquality;
    oCondition.Left = oVarName;
    oCondition.Right = 42;

    var strCode = Syntax.GenerateSource(oCondition);
    aqDlg.ShowMessage(strCode);
}

VBScript

Sub ShowConditionStatement
    Dim oCondition, oVarName, strCode

    Set oVarName = Syntax.CreateInvoke
    oVarName.InvokeName = "Answer"
    oVarName.IsProperty = True

    Set oCondition = Syntax.CreateCondition
    oCondition.OperatorType = oCondition.otEquality
    oCondition.Left = oVarName
    oCondition.Right = 42

    strCode = Syntax.GenerateSource(oCondition)
    aqDlg.ShowMessage strCode
End Sub

See Also

ConditionSyntax Object
CreateAssign Method
CreateCollection Method
CreateInvoke Method
CreateIf Method
CreateVarDef Method
AddSyntaxToScript Method

Highlight search results