Writing to a file in a standalone


    Jul 18 2018 | 7:43 pm
    Hello -
    I'm creating a standalone app on OSX that needs to write debug messages to a file. I'm using javascript to open the file and then appending lines as they are received from the various processes in the standalone.
    This works perfectly when I'm editing the project in Max, but does not work when compiled as a standalone.
    What I'm expecting is that the file "log.txt" would be created in the standalone's folder, and then opened with readwrite permissions. An empty file "log.txt" does get created, but the test .isopen always returns false. The same thing happens when I create the file ahead of time and place it into the standalone's folder.
    Can anyone help me with a method to make this work? Thanks, Jesse
    Here's the code to create a new file/open an existing one:
    var theLog;
    function initLog()
    {
    	var filename = "log.txt"
    	theLog = new File( filename, "readwrite" );
    	if( theLog.isopen )
    	{
    		printLine("opened file " + filename );
    		printLine("path = " + theLog.foldername );
     
    		theLog.position = theLog.eof;
    	}
    	else
    	{
    		printLine( "error: could not open file" );
    	}
    }