Write Method

Applies to TestComplete 15.45, last modified on December 01, 2022
This method is obsolete. See the Remarks section below.

Description

Use the Write method to write the specified value to a file. The value is written starting from the current position. If the position is not the end of the file, the specified value overwrites the previous data.

Declaration

aqBinaryFileObj.Write(Value)

aqBinaryFileObj An expression, variable or parameter that specifies a reference to an aqBinaryFile object
Value [in]    Required    Variant    
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Value

Defines the variant-compatible value to be written to a file.

Result Value

True if the value was written successfully, and False otherwise.

Remarks

  • On success, the cursor position is shifted by the length of the written data.

  • To use this method, you should open the needed file with the faWrite or faReadWrite access permission. See the description of the OpenBinaryFile method.

  • This method is obsolete and is not listed in the Code Completion window. It is supported for backward compatibility only. To write a value to a file, use a suitable method of the aqBinaryFile object depending on the type of the value.

Example

The following code writes a character at the end of a binary file. Note that you can specify the character's ASCII code or a string containing this character as the value of the method. The result will be the same.

JavaScript, JScript

function WritingDataToFile()
{
  MyFile=aqFile.OpenBinaryFile("C:\\MyFiles\\FileName.txt", 10)
  //Writing A to the end of the file
  MyFile.Write(65)
  //or
  MyFile.Write("A")
}

Python

def WritingDataToFile():
  MyFile = aqFile.OpenBinaryFile("C:\\MyFiles\\FileName.txt", 10)
  # Writing A to the end of the file
  MyFile.Write(65)
  # or
  MyFile.Write("A")

VBScript

sub WritingDataToFile
  Set MyFile=aqFile.OpenBinaryFile("C:\MyFiles\FileName.txt", 10)
  'Writing A to the end of the file
  MyFile.Write(65)
  'or
  MyFile.Write("A")
end sub

DelphiScript

procedure WritingDataToFile;
var MyFile: OleObject;
begin 
  MyFile:=aqFile.OpenBinaryFile('C:\MyFiles\FileName.txt', 10);
  //Writing A to the end of the file
  MyFile.Write(65);
  //or
  MyFile.Write('A');
end;

C++Script, C#Script

function WritingDataToFile()
{
  MyFile=aqFile["OpenBinaryFile"]('C:\MyFiles\FileName.txt', 10);
  //Writing A to the end of the file
  MyFile["Write"](65);
  //or
  MyFile["Write"]("A");
}

See Also

WriteByte Method

Highlight search results