Syntax.CreateCondition Method

Applies to TestComplete 12.60, last modified on September 17, 2018

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
Syntax.CreateAssign Method
Syntax.CreateCollection Method
Syntax.CreateInvoke Method
Syntax.CreateIf Method
Syntax.CreateVarDef Method
Recorder.AddSyntaxToScript Method

Highlight search results