Shoutbox

activex help - 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: activex help (/showthread.php?tid=70242)

activex help by Wakaki on 01-03-2007 at 10:58 AM

i have a window with a button save and when you click on it the values of 2 editcontrols  should be saved to tewo different textfiles and the window shoulkd close i don't understand how i should do this so plz help


RE: activex help by Matti on 01-03-2007 at 04:15 PM

Use the FileSystemObject! :)

code:
Original from MPScripts.net
// Writes content over an existing text file (replace the current text with new text)
function OverwriteFile (file, content) {
  var fileObj = new ActiveXObject("Scripting.FileSystemObject").OpenTextFile(MsgPlus.ScriptFilesPath + '\\' + file, 2, 0);
  fileObj.Write(content);
  fileObj.Close();
}

Use that function to write the content, like:
code:
OverwriteFile("file1.txt", PlusWnd.GetControlText("EdtThing1");
OverwriteFile("file2.txt", PlusWnd.GetControlText("EdtThing2");

If you need a function to read the contents again:
code:
Original from MPScripts.net
// Reads the full contents of a text file to a variable
function ReadFile (file) {
  var fileObj = new ActiveXObject("Scripting.FileSystemObject").OpenTextFile(MsgPlus.ScriptFilesPath + '\\' + file, 1);
  var contents = fileObj.ReadAll();
  fileObj.Close();
  return contents;
}

* Matti (L) the MP!L Script Developers Resource... thanks Dempsey!

RE: activex help by Wakaki on 01-03-2007 at 04:40 PM

thank you very much mattike but i only must happen when they press the button save


RE: activex help by Matti on 01-03-2007 at 05:10 PM

Well, then place it in an OnWindowidEvent_CtrlClicked event!

code:
// Writes content over an existing text file (replace the current text with new text)
function OverwriteFile (file, content) {
  var fileObj = new ActiveXObject("Scripting.FileSystemObject").OpenTextFile(MsgPlus.ScriptFilesPath + '\\' + file, 2, 0);
  fileObj.Write(content);
  fileObj.Close();
}

function OnWindowidEvent_CtrlClicked(PlusWnd, CtrlId) {
  if(CtrlId == "BtnSave") {
    OverwriteFile("file1.txt", PlusWnd.GetControlText("EdtThing1");
    OverwriteFile("file2.txt", PlusWnd.GetControlText("EdtThing2");
  }
}

RE: activex help by Wakaki on 01-03-2007 at 05:21 PM

thank you mattike


i've done this and then i get that i don't have prvileges so my script isn't started:S:S:S:S:S:S plz help
RE: activex help by roflmao456 on 01-03-2007 at 11:28 PM

try posting your code (or debug window of the error ) :gfdrin:


RE: activex help by Wakaki on 01-04-2007 at 09:59 AM

i was baout to do right now when i read your reply:P

EDIT: when i was cpying i discovered the fault:P bit silly when you look above in this thread and see the code mattike gave to me? then you see

code:
// + "file"
and then in the ctrlclicked function you see
code:
("myfile.txt", .......

and silly me made it :
code:
("//myfile.txt"......


so that was the error cause the script thought :
code:
////myfile.txt



thank you al for replying