Reads data from a binary file from the specified location.

syntaxSyntax:
DlxFile.ReadAt(index)

Parameters

Parameter Description
index The location of the byte to read. The value must be between 0 and GetLength()-1 .

Return Value

If the operation ends successfully, it returns the value of the byte contained at the specified location, otherwise it returns the value zero. If the file is of type text (opened with DlxApp.FILEOPEN_READTEXT) the value -1 is returned.

Example

  Copy codeCopy code
var filename = "demofile.bin";
// write file
var file = new DlxFile(filename, DlxApp.FILEOPEN_WRITEBINARY);
if (file.IsValid())
{
  for (var i = 0; i <= 90; i++)
	file.WriteByte(i);
  file.Close();
}
// read file
file = new DlxFile(filename, DlxApp.FILEOPEN_READBINARY);
if (file.IsValid())
{
  for (var i = 0; i <= 90; i++)
	DlxApp.Printf("%i", file.ReadAt(i));
  file.Close();
}
else DlxApp.Printf("File not found.");

See also