Shoutbox

Reading text file problem... - 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: Reading text file problem... (/showthread.php?tid=73967)

Reading text file problem... by Xocide on 04-27-2007 at 07:40 PM

Hi, I'm trying to make a script that reads from a text file that the script created itself, However whenever it reads a file all I get is:

quote:
˙ūt

Here is the code I'm using to read it:
code:
            var thetxtFile = '';
            var Message = '';
            var TheFile = 'test';
            FSO = new ActiveXObject("Scripting.FileSystemObject");
            if (FSO.FileExists(MsgPlus.ScriptFilesPath + "\\txtFiles\\" + TheFile + ".txt")) {
                    thetxtFile = FSO.OpenTextFile(MsgPlus.ScriptFilesPath + "\\txtFiles\\" + TheFile + ".txt", 1);
                Message = thetxtFile.ReadAll();
                Debug.Trace(Message);
            }


the file test.txt contains "test" in it.
RE: Reading text file problem... by TheGuruSupremacy on 04-27-2007 at 07:47 PM

quote:
Originally posted by Xocide
Hi, I'm trying to make a script that reads from a text file that the script created itself, However whenever it reads a file all I get is:


Here is the code I'm using to read it:
code:
            var thetxtFile = '';
            var Message = '';
            var TheFile = 'test';
            FSO = new ActiveXObject("Scripting.FileSystemObject");
            if (FSO.FileExists(MsgPlus.ScriptFilesPath + "\\txtFiles\\" + TheFile + ".txt")) {
                    thetxtFile = FSO.OpenTextFile(MsgPlus.ScriptFilesPath + "\\txtFiles\\" + TheFile + ".txt", 1);
                Message = thetxtFile.ReadAll();
                Debug.Trace(Message);
            }


the file test.txt contains "test" in it.

Hey Welcome on this forum!Please search before post next time;)...To solve your problem see TheGuRuSupremacy answer to How to read a text file
RE: RE: Reading text file problem... by Xocide on 04-27-2007 at 07:58 PM

quote:
Originally posted by TheGuruSupremacy
Hey Welcome on this forum!Please search before post next time;)...To solve your problem see TheGuRuSupremacy answer to How to read a text file


May I suggest you read, and test the code next time?
Where do you think I found the code to read a file?
RE: Reading text file problem... by vikke on 04-27-2007 at 08:02 PM

I have really no idea.. But Message could be a javascript array of the lines.

Also, try to change:

code:
var thetxtFile = '';
var Message = '';
var TheFile = 'test';
To:
code:
var thetxtFile = "";
var Message = "";
var TheFile = "test";

Edit: Now when I look at it it might be a unicode problem, but I don't see why, and cannot help you with that sorry.
RE: Reading text file problem... by TheGuruSupremacy on 04-27-2007 at 10:00 PM

quote:
Originally posted by Xocide
May I suggest you read, and test the code next time?
Where do you think I found the code to read a file?

I'm so sorry...You are right...However the code i(and you) have posted WORKS FINE for me...I don't know why it doesn't work for you
RE: Reading text file problem... by matty on 04-27-2007 at 10:28 PM

It is because the file is unicode not ansi.

Eljay's reply to unicode problem


RE: Reading text file problem... by CookieRevised on 04-28-2007 at 03:25 AM

quote:
Originally posted by Matty
It is because the file is unicode not ansi.

Eljay's reply to unicode problem
Although that code still has some major bugs. And as such shouldn't be used just like that without understanding the problems and major limitations it has.