TextFileLoad

From kwiki

Jump to: navigation, search
This article is written by Konrad, thus using rather nonstandard English:)

TextFileLoad (DNM Script function)

Contents

full declaration

string TextFileLoad (string sPath)

return value

string

description

Loads text file specified by sPath, and returns the result.

If GetLastError returns 0 the function succeeded, otherwise failed.

Advanced: GetLastAdditionalResult will return string, which may be one of the following:

"ansi": if the file was plain ASCII file

"utf-16 bom": if the file was UNICODE file and consisted BOM (in Windows most UNICODE files does)

"utf-16": if the file was UNICODE file

You can use this result in TextFileSave if you want to save the file in the same format as it was oryginally.

Examples

 //Text files sample, using TextFile... functions
 //let's save a file, if it doesn't exist - it will be created.
 TextFileSave("c:\\test file.txt","Hello world!");
 //Load it:
 var $s=TextFileLoad("c:\\test file.txt");
 //and show the contents:
 MessageBox($s);
 //Add some text:
 TextFileAppend("c:\\test file.txt"," Added text...");
 //again, load it:
 $s=TextFileLoad("c:\\test file.txt");
 //and again, show the contents:
 MessageBox($s);

See also


keywords: text file load read open contents files
Personal tools
konradp.com