Shoutbox

[Solved] Need help for concatenating strings - 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: [Solved] Need help for concatenating strings (/showthread.php?tid=85682)

[Solved] Need help for concatenating strings by pauleeer on 08-30-2008 at 11:52 PM

The problem is very stupid but I really can't find a solution.

My code is:

code:
        var fso = new ActiveXObject("Scripting.FileSystemObject");
        ts = fso.OpenTextFile(filepath, 1); //filepath does not contains errors
        ssvar = "The file contains: \n\n";
        var line = ""; 
        while(!ts.AtEndOfStream)
        {       
             line = ts.ReadLine();       
             if (line != "")
             {       
                 ssvar = ssvar + line; //This WONT work, how to concatenate strings??
                 Debug.Trace(line); //THIS trace correctly fires the line's text
             }           
        }
        ts.Close();

        Debug.Trace(ssvar);//THIS trace WONT display anything but "The file contains: \n\n"

As you can see this code is a piece of cake.. but I really can't figure out why it simply doesn't work. I've tried with ReadAll function but that function won't even read the file. The file is in ASCII text format and is less than 1 KB. Does not contains strange characters.

Help me please :(
RE: Need help for concatenating strings by matty on 08-31-2008 at 06:19 AM

What is the path you are passing to the function?

code:
var oFSO = new ActiveXObject('Scripting.FileSystemObject');

function ReadFile( filepath ) {
    if ( FileExists( filepath ) == true ) {
        var f = fso.OpenTextFile( filepath, 1 /* For_Reading */, false, (-2) /* TristateUseDefault  */ );
        return( f.ReadAll() );
    }
    return false;
}

function FileExists ( filepath ) { return oFSO.FileExists( filepath ); }

RE: Need help for concatenating strings by pauleeer on 08-31-2008 at 09:37 PM

Path was right but the file was written with a 00 byte at the beginning causing the program to read it wrong

Thanks for the help anyway! :D