AssignSyntax Object

Applies to TestComplete 14.61, last modified on April 22, 2021

Description

AssignSyntax objects are syntax elements that correspond to assignment statements. For example:

JavaScript, JScript

Answer = 42;

Python

Answer = 42;

VBScript

Answer = 42

DelphiScript

Answer := 42;

C++Script, C#Script

Answer = 42;

To create a AssignSyntax object instance, use the Syntax.CreateAssign method.

The AssignSyntax object provides properties to specify the expressions on the left and right sides of the assignment operator.

For more information about generating assignment code, see Generating Assignment Statements.

Members

Example

The following example demonstrates how you can use this object to generate the assignment statement given above:

JScript

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

  var oAssignment = Syntax.CreateAssign();
  oAssignment.Left = oVarName;
  oAssignment.Right = 42;

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

VBScript

Sub ShowAssignmentStatement
  Dim oVarName, oAssignment, strCode

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

  Set oAssignment = Syntax.CreateAssign
  oAssignment.Left = oVarName
  oAssignment.Right = 42

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

See Also

Script Extensions
Generating Assignment Statements
Syntax Object
CreateAssign Method

Highlight search results