Shoutbox

[Help] Writing text - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [Help] Writing text (/showthread.php?tid=84527)

[Help] Writing text by uNDeRGRouND99 on 06-26-2008 at 08:00 AM

Hi, i'm new and i'm a programmer of VB.Net and other, so i know how to program, so and so also in Script Plus.
My question is:
Why this don't work?

code:
function AddLineToFile (file, line) {
  if (!fsObj.FileExists(MsgPlus.ScriptFilesPath + '\\' + file))
    var fileObj = fsObj.OpenTextFile(MsgPlus.ScriptFilesPath + '\\' + file, 2, 1);
      else
        var fileObj = fsObj.OpenTextFile(MsgPlus.ScriptFilesPath + '\\' + file, 8, 0);
  fileObj.WriteLine(line);
  fileObj.Close();
}

I want a function for create a .txt and put in what i press (like keylogger) and upload it with ftp.
If i use AddLineToFile("lol.txt","hi"); for example, it don't work.

PS: MsgPlus.ScriptFilesPath is C:\Program Files\Messenger Plus! Live\Scripts\NameOfScript?
RE: [Help] Writing text by Matti on 06-26-2008 at 12:15 PM

It would have been helpful if you could provide the result of the script debugger, since now I have to guess what went wrong in your code. ;)

Anyway, assuming that fsObj is correctly defined as a FileSystemObject in the global scope, I firstly recommend you to remove the check of FileExists(). This is already implemented if you set the create attribute to true, and thus there's no need to check it yourself:

code:
var fsObj = new ActiveXObject("Scripting.FileSystemObject");

function AddLineToFile (file, line) {
  var fileObj = fsObj.OpenTextFile(MsgPlus.ScriptFilesPath + '\\' + file, /*ForAppending*/ 8, /*Create*/ 1);
  fileObj.WriteLine(line);
  fileObj.Close();
}
I don't know what else might be wrong with your code... :-/
RE: [Help] Writing text by uNDeRGRouND99 on 06-26-2008 at 01:43 PM

Yea, work, u are pr0.