Write variables to a .txt file

Hello.....I am looking for a little help with this, I'm trying to get this code to function, however I don't seem to be able to get this to write to the test.txt..

Thanks in advance...........

var player = GetPlayer();

var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.OpenTextFile("C:\\Test.txt", 8, true, 0);

var Firstname = player.GetVar("Firstname");

var Lastname = player.GetVar("Lastname");

var serialnumber = player.GetVar("serialnumber");

var Results.ScorePoints = player.GetVar("Results.ScorePoints");
s.WriteLine("Firstname: " + Firstname );
s.WriteLine("Lastname: " + Lastname);

s.WriteLine("serialnumber: " + serialnumber);

s.WriteLine("Results.ScorePoints: " + Results.ScorePoints);
s.WriteLine("==========");s.Close();

3 Replies
Ashley Terwilliger

Hi John, 

I wanted to welcome you to the E-Learning Heroes community, and there are a number of community members who may be able to look at your code to help point you in the right direction. Unfortunately it's not something I understand, but if there is anything else we can help you out with please let us know. 

Nicholas Soldatenko

Usually, browsers have very limited permissions to access to the file system with JavaScript. Even if you get it to work on one browser and for one user, I wouldn't expect this to be functional for everyone. Instead, consider saving the variables to the cloud: https://cluelabs.com/data-cloud-elearning-widget.html This way you're not relying on local permissions and settings of each unique learner.