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

Pages: (3): « First « 1 2 [ 3 ] Last »
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
TehGoatLord
New Member
*


Posts: 12
Joined: Nov 2010
O.P. RE: Read Text from a file
Thanks!
This works perfectly!

Thank you so much for the help, guys :D
11-07-2010 10:45 PM
Profile E-Mail PM Find Quote Report
Pages: (3): « First « 1 2 [ 3 ] 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