Previous Topic: gete--Get Environment Variable (Function)Next Topic: memoWrit--Write a String to a File (Function)


memoRead--Read a Text File Into a String (Function)

The memoRead() function reads a text file into a string.

Note: Using memoRead() on files containing binary information produces unpredictable results.

The function has the following syntax:

memoRead(sFileName [,nOffset] [,nCount])

The function returns the content of the text file as a JavaScript string.

sFilename

Specifies the name of a text file. If the specified file does not exist, the function creates an exception.

nOffset

(Optional) Specifies the number of characters from the beginning of the text file to the starting point of the read process.

nCount

(Optional) Specifies the number of characters that are read into a string.

Examples

Read Windows boot configuration:

s=memoRead("c:\boot.ini");
? s

Read a text file from offset 10 to the end of file:

s = memoRead("file.txt", 10);

Read five characters from a text file starting at offset 10:

s = memoRead("file.txt", 10, 5);

See also:

memoWrit--Write a String to a File (Function)

cat, type Commands--Display Text Files (Cmdlets)