Variables global vs local

Mar 29, 2016

Hi again

I am no programming wizard but I have done some scripting etc. This is likely several questions in one.

I am looking to create some custom slides that I can include as slide masters and reuse, in particular formative assessment slides which will give feedback but there will be no overall results and therefore between slides no data has to be stored (that I can foresee).

I may have up to about 10 input fields (mixed types) which will be checked against "correct responses" held in variables and then a feedback e.g. correct/incorrect for each input. So I am thinking 30 individual variables. Until all correct the student will not be able to move on.

If I reset all variables in each slide by an on start trigger then it will work but will require a good deal of messing about to customise each slide.

Am I correct that all variables are global and once set in a project are available throughout the project and that I cannot fix a variable as local to a slide or a scene.

Also if I take this approach, I will set variables at the start of every slide timeline on which the variable is used. I may then reset on end of slide timeline I havent thought this through. Each quizzing slide will then be a sort of a stand alone package.

Is this daft and is there a much easier way?

Any advice appreciated

Brian

 

4 Replies
Mike B.

Yes, I believe all variables in Storyline are global. Keep in mind that you can set or reset a bunch of variables at one time using one trigger that executes some javascript code.

var player = GetPlayer();
player.SetVar("var1",playerVar1);
player.SetVar("var2",playerVar2);
player.SetVar("var3",playerVar3);
player.SetVar("var4",playerVar4);
Christie Pollick

So glad to see that Mike offered an idea to assist you here, Brian, as JavaScript is not something for which we'd be able to provide support. If you have happen to have other questions, hopefully he or other JS gurus can chime in to assist, and in case you'd like to check it out, here is our JavaScript Best Practices and Examples info sheet. :)

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