Chrome's DevTools throwing a Syntax Error

May 12, 2020

Morning everyone,

Understanding that JS isn't officially supported, I've had success with implementing it in a number of Storyline courses over the last couple years, but I've run into a snag this last week with this latest project. It's been maybe six months since I last fiddled with JS so maybe something changed, but I just updated SL yesterday to make sure.

I'm sure it's a simple oversight, but I'm not seeing it for the life of me, so before heading over to StackExchange, I figured I'd post here.

I've attached  a screenshot showing all of the components. I can attach the project too if anyone wants. It's a fresh project to make sure everything is reset, so there's one slide, one button, and a text field.

Clicking the button executes the JS:

var p = GetPlayer();
p.SetVar("test") = "Success";

The Chrome console throws an "Invalid left-hand side in assignment."

The Use Count for the variable is 1, so SL knows the variables exists. I changed the JS to use a try-catch and the SetVar() assignment is throwing the error:

try {
var p = GetPlayer();
p.SetVar("varTest") = "Success.";
} catch (e) {
console.log("Broke.");
}

Anything anyone can offer or resources are very appreciated, thanks.

1 Reply
Andrew Blemings

Solved it, in case anyone comes after with the same issue.

I was getting the assignment error because the method doesn't allow assignment. I was misremembering the way the SetVar() method is called: with two arguments instead of one. 

Wrong: p.SetVar("varTest") = "Success.";

Should become:

Correct: p.SetVar("varTest", "Success.");

This discussion is closed. You can start a new discussion or contact Articulate Support.