What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Read Text from a file

Read Text from a file
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Read Text from a file
Now that's a useful error message! :D

Line 18 is:
js code:
line = line.replace('alias "serverinfo [', '');
This is just weird. I tried this myself and indeed, ReadLineFromFile returns false, meaning that the requested line number exceeds the amount of lines in the file. Apparently, the empty lines were omitted from the line array when doing the split(). However, when I replaced the regular expression by a normal string, it correctly produced an array with empty strings for empty lines! It appears that this is an inconsistency in the JScript implementation itself (thanks for that, Microsoft), so the only way to get around this is by using a string as separator or by writing your own split() method. In this case, using a string will do. :)

Just replace line 5 with:
js code:
    var FileContents = s.split("\n");
and it should work. In order to prevent further problems with this, you could add some error handling in case ReadLineFromFile returns false:
js code:
            var line = ReadLineFromFile("C:\\Program Files\\AssaultCube_v1.1.0.3\\config\\saved.cfg", 255, false);
            if( line === false ) return ''; // line not found, die silently
            line = line.replace('alias "serverinfo" [', '');
            // ...
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
11-07-2010 10:36 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Read Text from a file - by TehGoatLord on 11-07-2010 at 02:51 AM
RE: Read Text from a file - by matty on 11-07-2010 at 03:40 AM
RE: Read Text from a file - by TehGoatLord on 11-07-2010 at 04:47 AM
RE: Read Text from a file - by Matti on 11-07-2010 at 10:11 AM
RE: Read Text from a file - by TehGoatLord on 11-07-2010 at 02:02 PM
RE: Read Text from a file - by TehGoatLord on 11-07-2010 at 02:04 PM
RE: Read Text from a file - by matty on 11-07-2010 at 02:10 PM
RE: Read Text from a file - by TehGoatLord on 11-07-2010 at 04:47 PM
RE: Read Text from a file - by whiz on 11-07-2010 at 05:24 PM
RE: Read Text from a file - by TehGoatLord on 11-07-2010 at 06:09 PM
RE: Read Text from a file - by matty on 11-07-2010 at 06:30 PM
RE: Read Text from a file - by TehGoatLord on 11-07-2010 at 06:48 PM
RE: Read Text from a file - by Matti on 11-07-2010 at 07:42 PM
RE: Read Text from a file - by TehGoatLord on 11-07-2010 at 08:01 PM
RE: Read Text from a file - by matty on 11-07-2010 at 08:07 PM
RE: Read Text from a file - by TehGoatLord on 11-07-2010 at 08:14 PM
RE: Read Text from a file - by Matti on 11-07-2010 at 08:22 PM
RE: Read Text from a file - by TehGoatLord on 11-07-2010 at 08:30 PM
RE: Read Text from a file - by Matti on 11-07-2010 at 08:42 PM
RE: Read Text from a file - by TehGoatLord on 11-07-2010 at 08:51 PM
RE: Read Text from a file - by Matti on 11-07-2010 at 10:36 PM
RE: Read Text from a file - by TehGoatLord on 11-07-2010 at 10:45 PM


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