Access Property

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

Description

The Access property returns an integer value that corresponds to the access type of the property that the given aqObjPropertyObj object provides information about.

Declaration

aqObjPropertyObj.Access

Read-Only Property Integer
aqObjPropertyObj An expression, variable or parameter that specifies a reference to an aqObjProperty object

Applies To

The property is applied to the following object:

Property Value

One of the following integer values that define the access type of the property:

Value Description
2 Read-only access
4 Write-only access
6 Read-write access
8 Write-only access to a Visual Basic 6 object property that holds an object reference (that is, it is declared by using the Property Set statement).
10 Read-write access to a Visual Basic 6 object property that holds an object reference (that is, it is declared by using the Property Get and Property Set statements).

Example

The code below obtains the access type of the ChildCount property that belongs to Notepad's main window object.

JavaScript, JScript

function GetAccessType()
{

  // Launches notepad.exe
  WshShell.Run("notepad.exe", SW_NORMAL);
  
  // Specifies the object
  var Obj = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1);
  
  // Obtains information about the ChildCount property
  var sProperty = aqObject.GetProperties(Obj).Item(1);
  
  switch (sProperty.Access)
  {
    case 2 :
    {
      Log.Message("The specified property is read-only.");
      break;
    }
    case 4 :
    {
      Log.Message("The specified property is write-only.");
      break;
    }
    case 6 :
    {
      Log.Message("The specified property is read-write.");
      break;
    }
    case 8 :
    {
      Log.Message("The specified property is write-only and holds an object reference.");
      break;
    }
    case 10 :
    {
      Log.Message("The specified property is read-write and holds an object reference.");
      break;
    }
  }
  
  // Closes notepad.exe
  Sys.Process("notepad").Terminate();
  
}

Python

def GetAccessType():
  # Launches notepad.exe
  WshShell.Run("notepad.exe", SW_NORMAL)
  # Specifies the object
  Obj = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1)
  # Obtains information about the ChildCount property
  sProperty = aqObject.GetProperties(Obj).Item(1)
  if sProperty.Access == 2:
    Log.Message("The specified property is read-only.")
  elif sProperty.Access == 4:
    Log.Message("The specified property is write-only.")
  elif sProperty.Access == 6:
    Log.Message("The specified property is read-write.")
  elif sProperty.Access == 8: 
    Log.Message("The specified property is write-only and holds an object reference.")
  elif sProperty.Access == 10:
    Log.Message("The specified property is read-write and holds an object reference.")
  # Closes notepad.exe
  Sys.Process("notepad").Terminate()

VBScript

Sub GetAccessType

  ' Launches notepad.exe
  Call WshShell.Run("notepad.exe", SW_NORMAL)
  
  ' Specifies the object
  Set Obj = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1)
  
  ' Obtains information about the ChildCount property
  Set sProperty = aqObject.GetProperties(Obj).Item(1)
  
  Select case sProperty.Access
    case 2 : Log.Message "The specified property is read-only."
    case 4 : Log.Message "The specified property is write-only."
    case 6 : Log.Message "The specified property is read-write."
    case 8 : Log.Message "The specified property is write-only and holds an object reference."
    case 10 : Log.Message "The specified property is read-write and holds an object reference."
  End Select
  
    ' Closes notepad.exe
  Sys.Process("notepad").Terminate
  
End Sub

DelphiScript

function GetAccessType;
var Obj, sProperty;
begin

  // Launches notepad.exe
  WshShell.Run('notepad.exe', SW_NORMAL);
  
  // Specifies the object
  Obj := Sys.Process('notepad').Window('Notepad', 'Untitled - Notepad', 1);
  
  // Obtains information about the ChildCount property
  sProperty := aqObject.GetProperties(Obj).Item[1];
  
  case (sProperty.Access) of
    2 : Log.Message('The specified property is read-only.');
    4 : Log.Message('The specified property is write-only.');
    6 : Log.Message('The specified property is read-write.');
    8 : Log.Message('The specified property is write-only and holds an object reference.');
    10 : Log.Message('The specified property is read-write and holds an object reference.');
  end;
  
  // Closes notepad.exe
  Sys.Process('notepad').Terminate();
  
end;

C++Script, C#Script

function GetAccessType()
{

  // Launches notepad.exe
  WshShell["Run"]("notepad.exe", SW_NORMAL);
  
  // Specifies the object
  var Obj = Sys["Process"]("notepad")["Window"]("Notepad", "Untitled - Notepad", 1);
  
  // Obtains information about the ChildCount property
  var sProperty = aqObject["GetProperties"](Obj)["Item"](1);
  
  switch ( sProperty["Access"] )
  {
    case 2 :
    {
      Log["Message"]("The specified property is read-only.");
      break;
    }
    case 4 :
    {
      Log["Message"]("The specified property is write-only.");
      break;
    }
    case 6 :
    {
      Log["Message"]("The specified property is read-write.");
      break;
    }
    case 8 :
    {
      Log["Message"]("The specified property is write-only and holds an object reference.");
      break;
    }
    case 10 :
    {
      Log["Message"]("The specified property is read-write and holds an object reference.");
      break;
    }
  }
  
  // Closes notepad.exe
  Sys["Process"]("notepad")["Terminate"]();
  
}

See Also

Name Property
ParamCount Property
Value Property

Highlight search results