What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » How do I save data?????

Pages: (2): « First « 1 [ 2 ] Last »
How do I save data?????
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: How do I save data?????
quote:
Originally posted by Spunky
Although I'm sure there should be an f.Close(); before the return. This is taken from MSDN though
Indeed there should. It wouldn't be the first time some info or code on the MSDN Library is faulty. This said, at least all the complete function examples on the MSDN Library overview page in regards to reading/writing files do include the Close() statement.


------------

quote:
Originally posted by Infinity8888
this wasn't discussed in the messenger plus documentation.
Because the Messenger Plus! Scripting documentation help file (or the online docs) is about... well... Messenger Plus! stuff. It is specifically about Plus! objects, Plus! functions and Plus! events in the integrated scripting language. All the other normal things you could do in JScript are out of scope of this documentation.

So, writing to files and all kind of other stuff is pure JScript and nothing todo with Plus! specifically and thus you'll find info about that in the Windows Scripting Documentation help file (or online docs) instead.

There you'll find example code as posted by Spunky. Although, there are some small errors in Spunky's code. Below, the fixed lines in yellow:
Javascript code:
function Write(filename, text){
   try{
      var fso = new ActiveXObject("Scripting.FileSystemObject");
      var f = fso.OpenTextFile(filename, 2, true);      f.Write(text);
      f.Close();
      return 1;
   }catch(e){
      Debug.Trace("Write Error: (File '"+filename+"': " + e.message);
      return 0;
   }
}
 
function Read(filename){   try{
      var fso = new ActiveXObject("Scripting.FileSystemObject");      var f = fso.OpenTextFile(filename, 1);      var r = f.ReadLine();      f.Close();      return r;   }catch(e){
      Debug.Trace("Read Error: (File '"+filename+"': " + e.message);
      return 0; // Failed
   }
}



;)

This post was edited on 07-02-2011 at 11:20 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
07-02-2011 10:43 PM
Profile PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: How do I save data?????
quote:
Originally posted by CookieRevised
Although, there are some small errors in Spunky's code

Damn, was in a rush :p Good to know that the Close() was needed though (Y)
<Eljay> "Problems encountered: shit blew up" :zippy:
07-02-2011 11:48 PM
Profile PM Find Quote Report
Infinity8888
New Member
*


Posts: 6
Joined: Jul 2011
O.P. RE: How do I save data?????
Yeah I added the Close() yesterday because I wasn't able to erase the files I was working with because they were still used by messenger.

I just needed something to start with. Thank you very much
07-03-2011 05:22 PM
Profile E-Mail PM Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On