Read

Read is used to read a string of (x) length from a text file.

Syntax

Read(number_of_bytes, [DataType])

Returns

String.

More Information

DataType is an optional parameter. If omitted the correct data type will be auto detected by the system.

Possible options for the DataType parameter are as follow:

  • 0 – Return buffer as an array of bytes (ideal for raw data).
  • 1 – Return Buffer as a string (ideal if you know that the buffer consists of raw text)
  • 2 – Return buffer as string, non printable characters are ignored. This is Ideal when you know that the buffer is mixed between plain text and special characters but when you’re just interested in the plain text part.
Example

This script displays the contents of the hosts file:

Function Main

Dim textfile As Object

Set textfile = File.Connect("127.0.0.1")

If textfile.Open("c:\windows\system32\drivers\etc\hosts", GENERIC_READ, Open_Existing) Then

echo(textfile.read(1024,1))

textfile.Close

End If

End Function