Performing calculations in Storyline
Jul 26, 2012
By
Chuck Nemer
Hi all: I have a request from a client to create a simple calculator they can use in their training. If you're a statistics geek, it's a Cp and Cpk calculator. Basically whether or not a process is capable of meeting the requirements set down. Mathematically it means the learner will input three data values and I have to subtract the second from the first and divide the result by 6 times the third value and then show the result.
There is so much good stuff on the web site I'm finding it hard to just find a basic tutorial on doing calculations in Storyline. Any help would be appreciated
Thanx
Chuck
4 Replies
Hi, Chuck -
Certainly possible in Storyline. If you're not averse to using JavaScript I think that would be the easiest and most elegant pathway to getting the calculator finished. Keeping in mind this method won't work at all in the iOS player on iPad and won't work yet in HTML5 output.
Fields with correlating variables:
val1
val2
val3
result1
Calculate with trigger (JavaScript Trigger):
var player=GetPlayer();
var jsVal1=player.GetVar("val1");
var jsVal2=player.GetVar("val2");
var jsVal3=player.GetVar("val3");
var calcResult=(jsVal1-jsVal2)/(jsVal3*6);
player.SetVar("result1",calcResult);
Hi Steve: Thanx for the quick response. I understand the logic of your example. A couple things. Where do I do this in Storyline? Is it in triggers? Do I create a trigger and embed this? the other thing is I bought storyline because it does it's programming behind the object for me. I love programming and get it, but it's not a good use of my time work wise to learn java. I get your example, the logic, and the flow. Can't visualize how I'd do it and where in Storyline
Hi, Chuck -
There are other ways to do this with variables. The method I described above uses the Javascript trigger:
Cool Steve: If I can write out in english what i want to perform for calculations, can you help me write the Javascript? It's going to be simple and I get now what you're saying. If I can see how it would be written I can reverse engineer my thinking and understand what you're teaching me
Thanx
Chuck
This discussion is closed. You can start a new discussion or contact Articulate Support.