quote:
Originally posted by pedro_cesar
Are function as feof, fget*, etc available in JavaScript?
No. Those are PHP functions and they don't exist as standard JScript functions. To access files, you'll have to use the FileSystemObject or use API calls. You can take a look at
the code snippet on the MPScripts.net site and use those functions to read from or write to text files.
Note: the functions in the snippet use a variable called 'fsObj', this can be declared in global like this:
code:
var fsObj = new ActiveXObject("Scripting.FileSystemObject")
but it's recommend you declare it per function to keep the memory usage low. This means, that instead of using:
code:
// Reads the full contents of a text file to a variable
function ReadFile (file) {
var fileObj = fsObj.OpenTextFile(MsgPlus.ScriptFilesPath + '\\' + file, 1);
var contents = fileObj.ReadAll();
fileObj.Close();
return contents;
}
you use
code:
// Reads the full contents of a text file to a variable
function ReadFile (file) {
var fsObj = new ActiveXObject("Scripting.FileSystemObject");
var fileObj = fsObj.OpenTextFile(MsgPlus.ScriptFilesPath + '\\' + file, 1);
var contents = fileObj.ReadAll();
fileObj.Close();
return contents;
}
and so on for the other functions.