Count Property

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

Use the aqBytesObj.Count property to get the length of the byte sequence provided by the aqBytes object.

Declaration

aqBytesObj.Count

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

Applies To

The property is applied to the following object:

Property Value

The length of the byte sequence.

Example

The code below obtains binary data of the specified file and posts the size of the byte sequence to the test log.

JavaScript, JScript

function CountBytes()
 {
   Path = "C:\MyFiles\FileName.txt";
   
   // Opens the specified file for reading in binary mode
   myFile = aqFile.OpenBinaryFile(Path, aqFile.faRead);
   
   // Reads bytes from the file
   readBytes = myFile.ReadBytes();
   
   // Get the length of the byte sequence
   countBytes = readBytes.Count;
   Log.Message("The number of bytes: " + countBytes);

   myFile.Close();
 }

Python

def CountBytes():
   Path = "C:\\MyFiles\FileName.txt"
   
   # Opens the specified file for reading in binary mode
   myFile = aqFile.OpenBinaryFile(Path, aqFile.faRead)
   
   # Reads bytes from the file
   readBytes = myFile.ReadBytes()
   
   # Get the length of the byte sequence
   countBytes = readBytes.Count
   Log.Message("The number of bytes: " + aqConvert.VarToStr(countBytes))

   myFile.Close()

VBScript

Sub CountBytes
Dim Path, myFile, readBytes, countBytes
   
   Path = "C:\MyFiles\FileName.txt"
   
   ' Opens the specified file for reading in binary mode
   Set myFile = aqFile.OpenBinaryFile(Path, aqFile.faRead)
   
   ' Reads bytes from the file
   Set readBytes = myFile.ReadBytes()
   
   ' Get the length of the byte sequence
   countBytes = readBytes.Count
   Log.Message("The number of bytes: " + aqConvert.VarToStr(countBytes))
   
   myFile.Close()
End Sub

DelphiScript

procedure CountBytes;
var Path, myFile, readBytes, countBytes;
begin
    Path := 'C:\MyFiles\FileName.txt';
    
    // Opens the specified file for reading in binary mode
    myFile := aqFile.OpenBinaryFile(Path, aqFile.faRead);
       
    // Reads bytes from the file
    readBytes := myFile.ReadBytes();
    
    // Get the length of the byte sequence
    countBytes := readBytes.Count;
    Log.Message('The number of bytes: ' + aqConvert.VarToStr(countBytes));

    myFile.Close();
end;

C++Script, C#Script

function CountBytes()
 {
   Path = "C:\\MyFiles\\FileName.txt";
   
   // Opens the specified file for reading in binary mode
   myFile = aqFile["OpenBinaryFile"](Path, aqFile["faRead"]);
   
   // Reads bytes from the file
   readBytes = myFile["ReadBytes"]();
   
   // Get the length of the byte sequence
   countBytes = readBytes["Count"];
   Log["Message"]("The number of bytes: " + aqConvert["VarToStr"](countBytes));

   myFile["Close"]();
 }

See Also

aqBytes Object
Item Property
SetItem Method

Highlight search results