Description
The ReadBool
method retrieves two bytes from a binary file (starting from the current cursor position) and treats them as Boolean value.
Declaration
aqBinaryFileObj.ReadBool()
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
The Boolean value read from the file.
Remarks
On success, the cursor position is shifted by 2 bytes.
Example
The code below opens a file for reading, posts its data to the test log in different formats (binary, boolean, and so on) and then closes the file.
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.WriteBool(false);
myFile.WriteCurrency(3000000000);
myFile.WriteDate(aqDateTime.Today());
myFile.WriteFloat(1543.514)
myFile.WriteInt(58942);
myFile.WriteString("Hello!");
// Closes the file
myFile.Close();
// Opens the file for reading
myFile = aqFile.OpenBinaryFile(Path, aqFile.faRead);
// Reads data from the file in different formats
Log.Message("The bolean is: "+ myFile.ReadBool());
Log.Message("The currency is: "+ myFile.ReadCurrency());
Log.Message("The date is: " + myFile.ReadDate());
Log.Message("The float number is: " + myFile.ReadFloat());
Log.Message("The integer number is: "+ myFile.ReadInt());
Log.Message("The string is: "+ myFile.ReadString(6));
// Closes the file
myFile.Close();
}
/*
The routine produces the following output:
The bolean is: false
The currency is: 3000000000
The date is: Wed Jun 23 00:00:00 UTC+0400 2010
The float number is: 1543.514
The integer number is: 58942
The string is: Hello!
*/
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(False)
myFile.Write(3000000000)
myFile.Write(aqDateTime.Today())
myFile.Write(1543.514)
myFile.Write(58942)
myFile.Write("Hello!")
# Closes the file
myFile.Close()
# Opens the file for reading
myFile = aqFile.OpenBinaryFile(Path, aqFile.faRead)
# Reads data from the file in different formats
Log.Message("The bolean is: "+ str(myFile.ReadBool()))
Log.Message("The currency is: "+ str(myFile.ReadCurrency()))
Log.Message("The date is: " + str(myFile.ReadDate()))
Log.Message("The float number is: " + str(myFile.ReadFloat()))
Log.Message("The integer number is: "+ str(myFile.ReadInt()))
Log.Message("The string is: "+ myFile.ReadString(6))
# Closes the file
myFile.Close();
# The routine produces the following output:
# The bolean is: False
# The currency is: 3000000000
# The date is: Wed Jun 23 00:00:00 UTC+0400 2010
# The float number is: 1543.514
# The integer number is: 58942
# The string is: Hello!
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.WriteBool(false)
Call myFile.WriteCurrency(3000000000)
Call myFile.WriteDate(aqDateTime.Today())
Call myFile.WriteFloat(1543.514)
Call myFile.WriteInt(58942)
Call myFile.WriteString("Hello!")
' 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 in different formats
Call Log.Message("The bolean is: "+ aqConvert.VarToStr(myFile.ReadBool()))
Call Log.Message("The currency is: "+ aqConvert.CurrencyToStr(myFile.ReadCurrency()))
Call Log.Message("The date is: " + aqConvert.DateTimeToStr(myFile.ReadDate()))
Call Log.Message("The float number is: " + aqConvert.FloatToStr(myFile.ReadFloat()))
Call Log.Message("The integer number is: "+ aqConvert.IntToStr(myFile.ReadInt()))
Call Log.Message("The string is: "+ myFile.ReadString(6))
' Closes the file
Call myFile.Close()
End Sub
' The routine produces the following output:
' The bolean is: false
' The currency is: 3000000000
' The date is: Wed Jun 23 00:00:00 UTC+0400 2010
' The float number is: 1543.514
' The integer number is: 58942
' The string is: Hello!
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.WriteBool(false);
myFile.WriteCurrency(3000000000);
myFile.WriteDate(aqDateTime.Today());
myFile.WriteFloat(1543.514);
myFile.WriteInt(58942);
myFile.WriteString('Hello!');
// Closes the file
myFile.Close();
// Opens the file for reading
myFile := aqFile.OpenBinaryFile(Path, aqFile.faRead);
// Reads data from the file in different formats
Log.Message('The bolean is: '+ myFile.ReadBool());
Log.Message('The currency is: '+ myFile.ReadCurrency());
Log.Message('The date is: ' + myFile.ReadDate());
Log.Message('The float number is: ' + myFile.ReadFloat());
Log.Message('The integer number is: '+ myFile.ReadInt());
Log.Message('The string is: '+ myFile.ReadString(6));
// Closes the file
myFile.Close();
end;
{
The routine produces the following output:
The bolean is: false
The currency is: 3000000000
The date is: Wed Jun 23 00:00:00 UTC+0400 2010
The float number is: 1543.514
The integer number is: 58942
The string is: Hello!
}
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["WriteBool"](false);
myFile["WriteCurrency"](3000000000);
myFile["WriteDate"](aqDateTime.Today());
myFile["WriteFloat"](1543.514)
myFile["WriteInt"](58942);
myFile["WriteString"]('Hello!');
// Closes the file
myFile["Close"]();
// Opens the file for reading
myFile = aqFile["OpenBinaryFile"](Path, aqFile.faRead);
// Reads data from the file in different formats
Log["Message"]( "The bolean is: "+ myFile["ReadBool"]() );
Log["Message"]( "The currency is: "+ myFile["ReadCurrency"]() );
Log["Message"]( "The date is: " + myFile["ReadDate"]());
Log["Message"]( "The float number is: " + myFile["ReadFloat"]() );
Log["Message"]( "The integer number is: "+ myFile["ReadInt"]() );
Log["Message"]( "The string is: "+ myFile["ReadString"](6) );
// Closes the file
myFile["Close"]();
}
/*
The routine produces the following output:
The bolean is: false
The currency is: 3000000000
The date is: Wed Jun 23 00:00:00 UTC+0400 2010
The float number is: 1543.514
The integer number is: 58942
The string is: Hello!
*/
See Also
Working With Files From Scripts
WriteBool Method
ReadInt Method
ReadByte Method
ReadBytes Method
ReadShort Method
ReadCurrency Method
ReadInt64 Method
ReadFloat Method
ReadString Method
ReadDate Method