Posted by Brent in SWF Studio V3 on Jan 21 2008, 09:29 am

Hello, I'm having trouble writing to a text file.
I've tried alot of different things. I can't figure it out at all. If some one could put up basic code that would work that'd be a big help or atleast tell me what's wrong with mine. Thanks in advance.

ssCore.init();
ssDefaults.synchronousCommands = true;
var returnObject = ssCore.FileSys.writeToFile({path:"\\text.txt", data:"test!"} );
if (return_obj.success)
{
    if (return_obj.result == "YES")
    {
      Label="success";
    }
}
else
{
Label="fail";
}


Posted by northcode in SWF Studio V3 on Jan 21 2008, 09:58 am

The code you had was very close.

FileSys.writeToFile has no output parameters so there's no result_obj.result to check, just the result_obj.success that exists for every command (it's part of the ssCore framework).

Almost everywhere you see a path parameter in SWF Studio it should be a fully qualified path, relative paths won't work in ssCore commands. I've changed your \\text.txt to c:\\text.txt as an example. You can also use File Monikers in paths you pass to ssCore if the documentation says This parameter supports monikers. like it does for FileSys.writeToFile. Monikers allow you to do what you normally could have done with a relative path. For example startdir://text.txt refers to a path in the same folder as your application. Check out the link to File Monikers for more locations you can refer to with monikers.


ssCore.init();
ssDefaults.synchronousCommands = true;

var returnObject = ssCore.FileSys.writeToFile({path:"c:\\text.txt", data:"test!"} );
if (return_obj.success)
{
   Label="success";
}
else
{
   Label="fail";
}
If that's still not working you should also check the Plugins Tab and make sure the FileSys plugin has been selected before you do your build.


Posted by Brent in SWF Studio V3 on Jan 21 2008, 01:19 pm

Thanks alot that was a big help :)