Very simple JavaScript call not returning a variable

Posted Just now

I'm can't get JavaScript to manipulate variables fetched from Storyline and I have no idea what I'm doing wrong. Probably something idiotically straightforward - I hope so!

My very simple test sends two text variables using JavaScript, concatenates them and should send back a single, combined variable.

This is the JavaScript:

var FirstName = player.GetVar("First");

var LastName = player.GetVar("Last");

var FullName = FirstName + Last Name

var player = GetPlayer();

player.SetVar("CompleteName",FullName);

I attach the Storyline file. I published it for CD and have tried it on different Windows 7 and XP systems but still no variable is being returned. What a pain it is to simply manipulate text in this way, inside or outside of Storyline. I used Authorware for 20 years and have been spoiled by terrific facilities in this area!

Any ideas?

Many thanks, Tim

3 Replies
Tim Neill

Phil, at the risk of being greedy I've also been trying without success to get the JavaScript code to work to save a Storyline variable to a .txt file, in a CD-published program.

I used the exact code given in the Support page athttp://www.articulate.com/support/storyline/javascript-best-practices-and-examples but it's not writing a txt file. I've looked through the various threads on this but I'm still stuck.

My JavaScript code is below, I set the SL variable 'First' to a name:

var fso = new ActiveXObject("Scripting.FileSystemObject");

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

var name = player.GetVar("First");

s.WriteLine("Name: " + name);

s.WriteLine("==========");

s.Close();

Many thanks, Tim