ReadInt64 Method

Applies to TestComplete 14.80, last modified on April 13, 2021

Description

The ReadInt64 method retrieves 8 bytes from a binary file (starting from the current cursor position) and treats them as a long integer value.

Declaration

aqBinaryFileObj.ReadInt64()

aqBinaryFileObj An expression, variable or parameter that specifies a reference to an aqBinaryFile object
Result 64-bit Integer

Applies To

The method is applied to the following object:

Result Value

The integer value read from the file.

Remarks

On success, the cursor position is shifted by 8 bytes (the length of a 64-bit integer value).

Keep in mind that writing an integer value shifts the cursor position either by 4 or by 8 bytes, whereas reading an integer value can shift the position by 1-8 bytes depending on the method used.

Example

The code below demonstrates how to use the ReadInt64 method.

JavaScript, JScript

function ReadingDataFromBinaryFile()
{
 Path = "C:\\MyFiles\\FileName.txt";
 
 // Creates a new file and opens it for writing in binary mode
 myFile = aqFile.OpenBinaryFile(Path, aqFile.faWrite, true);
 
 // Writes data to the file
  myFile.Write(2000000000);
 
 // Closes the file
 myFile.Close();
 
 // Opens the file for reading
 myFile = aqFile.OpenBinaryFile(Path, aqFile.faRead);
 
 // Reads data from the file
 Log.Message(myFile.ReadInt64());
  
 // Closes the file
 myFile.Close();
}

Python

def ReadingDataFromBinaryFile():
  Path = "C:\\MyFiles\\FileName.txt"
  # Creates a new file and opens it for writing in binary mode
  myFile = aqFile.OpenBinaryFile(Path, aqFile.faWrite, True)
  # Writes data to the file
  myFile.Write(2000000000)
  # Closes the file
  myFile.Close()
  # Opens the file for reading
  myFile = aqFile.OpenBinaryFile(Path, aqFile.faRead)
  # Reads data from the file 
  Log.Message(myFile.ReadInt64())
  # Closes the file
  myFile.Close()

VBScript

Sub ReadingDataFromBinaryFile
Dim Path, myFile
 'Set Path = "C:\MyFiles\FileName.txt"
 
 ' Creates a new file and opens it for writing in binary mode
 Set myFile = aqFile.OpenBinaryFile("C:\MyFiles\FileName.txt", aqFile.faWrite, true)
 
 ' Writes data to the file
  Call myFile.Write(2000000000)
 
 ' Closes the file
 Call myFile.Close
 
 ' Opens the file for reading
 Set myFile = aqFile.OpenBinaryFile("C:\MyFiles\FileName.txt", aqFile.faRead)
 
 ' Reads data from the file
  Call Log.Message(aqConvert.IntToStr(myFile.ReadInt64))
 
 ' Closes the file
 Call myFile.Close
End Sub

DelphiScript

procedure ReadingDataFromBinaryFile;
var Path, myFile: OleObject;
begin
 Path := 'C:\MyFiles\FileName.txt';
 
 // Creates a new file and opens it for writing in binary mode
 myFile := aqFile.OpenBinaryFile(Path, aqFile.faWrite, true);
 
 // Writes data to the file
 myFile.Write(2000000000);
 
 // Closes the file
 myFile.Close;
 
 // Opens the file for reading
 myFile := aqFile.OpenBinaryFile(Path, aqFile.faRead);
 
 // Reads data from the file
 Log.Message(aqConvert.IntToStr(myFile.ReadInt64));
  
 // Closes the file
 myFile.Close;
end;

C++Script, C#Script

function ReadingDataFromBinaryFile()
{
 Path = "C:\\MyFiles\\FileName.txt";
 
 // Creates a new file and opens it for writing in binary mode
 myFile = aqFile["OpenBinaryFile"](Path, aqFile.faWrite, true);
 
 // Writes data to the file
 myFile["Write"](2000000000);

 // Closes the file
 myFile["Close"]();
 
 // Opens the file for reading
 myFile = aqFile["OpenBinaryFile"](Path, aqFile.faRead);
 
 // Reads data from the file
 Log["Message"]( myFile["ReadInt64"]() );
  
 // Closes the file
 myFile["Close"]();
}

See Also

Working With Files From Scripts
WriteInt64 Method
ReadInt Method
ReadByte Method
ReadBytes Method
ReadShort Method
ReadCurrency Method
ReadFloat Method
ReadString Method
ReadBool Method
ReadDate Method

Highlight search results