aqUtils.IsValidIdent Method

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

Use the aqUtils.IsValidIdent method to determine whether the string specified by the Ident parameter is a valid JavaScript, JScript, Python, C++Script, C#Script or DelphiScript identifier. A valid identifier may include only alphanumeric characters ('A'..'Z', 'a'..'z' and '0'..'9') and underscores ('_') and cannot start with a digit.

Declaration

aqUtils.IsValidIdent(Ident)

Ident [in]    Required    String    
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Ident

Specifies the string that TestComplete will check to determine whether it is a valid JavaScript, JScript, Python, C++Script, C#Script or DelphiScript identifier.

Result Value

The method returns True if the string specified by the Ident parameter is a valid JavaScript, JScript, Python, C++Script, C#Script or DelphiScript identifier. Otherwise, the method returns False.

Remarks

You can also use this function to validate VBScript identifiers. These identifiers must match all the rules applied to the JavaScript, JScript, Python, C++Script, C#Script and DelphiScript identifiers with the only exception: a VBScript identifier cannot start with an underscore (_).

Example

The code below checks validity of the specified identifier.

JavaScript, JScript

function CheckIdentifierValidity()
{
  var Ident = "IdentifierName_123";
  if ( aqUtils.IsValidIdent(Ident) )
    Log.Message("The specified string can be used as an identifier.")
  else
    Log.Error("The specified identifier is not supported.");
}

Python

def CheckIdentifierValidity():
  Ident = "IdentifierName_123"
  if aqUtils.IsValidIdent(Ident):
    Log.Message("The specified string can be used as an identifier.")
  else:
    Log.Error("The specified identifier is not supported.")

VBScript

Sub CheckIdentifierValidity

  Ident = "IdentifierName_123"
  If aqUtils.IsValidIdent(Ident) Then
    Log.Message("The specified string can be used as an identifier.")
  Else
    Log.Error("The specified identifier is not supported.")
  End If
  
End Sub

DelphiScript

function CheckIdentifierValidity;
var Ident;
begin
  Ident := 'IdentifierName_123';
  if ( aqUtils.IsValidIdent(Ident) ) then
    Log.Message('The specified string can be used as an identifier.')
  else
    Log.Error('The specified identifier is not supported.');
end;

C++Script, C#Script

function CheckIdentifierValidity()
{
  var Ident = "IdentifierName_123";
  if ( aqUtils["IsValidIdent"](Ident) )
    Log["Message"]("The specified string can be used as an identifier.")
  else
    Log["Error"]("The specified identifier is not supported.");
}

See Also

Object-Driven Testing

Highlight search results