IsEndOfFile Method

Applies to TestComplete 14.20, last modified on September 11, 2019

Description

Use the IsEndOfFile method to verify whether the cursor position is at the end of the file.

Declaration

aqBinaryFileObj.IsEndOfFile()

aqBinaryFileObj An expression, variable or parameter that specifies a reference to an aqBinaryFile object
Result Boolean

Applies To

The method is applied to the following object:

Result Value

True if the end of the file has been reached, and False otherwise.

Example

The code below demonstrates how you can use the IsEndOfFile method to read all the data from a binary file.

JavaScript, JScript

function ReadingFileContent()
{

  // Opens the file for reading
  MyFile=aqFile.OpenBinaryFile("C:\\MyFiles\\FileName.txt", aqFile.faRead);

  // Reads the file content
  while (!MyFile.IsEndOfFile () );
  {
    Log.Message(MyFile.ReadByte());
  }

  // Closes the file
  MyFile.Close();

}

Python

def ReadingFileContent():
  # Opens the file for reading
  MyFile=aqFile.OpenBinaryFile("C:\\MyFiles\\FileName.txt", aqFile.faRead)
  # Reads the file content
  while not MyFile.IsEndOfFile():
    Log.Message(MyFile.ReadByte())
  # Closes the file
  MyFile.Close()

VBScript

Sub ReadingFileContent

  ' Opens the file for reading
  Set MyFile=aqFile.OpenBinaryFile("C:\MyFiles\FileName.txt", aqFile.faRead)

  ' Reads the file content
  While Not MyFile.isEndofFile
    Log.Message(MyFile.ReadByte)
  Wend

  ' Closes the file
  MyFile.Close

End Sub

DelphiScript

procedure ReadingFileContent;
var MyFile: OleObject;
begin 

  // Opens the file for reading
  MyFile:=aqFile.OpenBinaryFile('C:\MyFiles\FileName.txt', aqFile.faRead);

  // Reads the file content
  while not MyFile.IsEndOfFile() do
  begin
    Log.Message(MyFile.ReadByte);
  end;

  // Closes the file
  MyFile.Close();

end;

C++Script, C#Script

function ReadingFileContent()
{

  // Opens the file for reading
 MyFile=aqFile["OpenBinaryFile"]( "C:\\MyFiles\\FileName.txt", aqFile.faRead );

  // Reads the file content
 while (! MyFile["IsEndOfFile"]() )
  {
    Log["Message"]( MyFile["ReadByte"]() );
  }

  // Closes the file
 MyFile ["Close"]();

}

See Also

Working With Files From Scripts

Highlight search results