Calculations with Variables in Storyline
May 17, 2012
Hi everyone. I have been playing with variables and calculations in storyline a little and wonder if anyone has some good examples they would be willing to share. I have been able to get what I want but think there might be better/quicker ways. Here is what I have done:
1. create two number input variables: CurrentWeight & PercentBodyFat
2. Create three other variables: IdealWeight, Step1, Step2
3. Assign a default value of 100 to Step1
The equation I want is CurrentWeight*(100-PercentBodyFat)/0.8 = IdealWeight
I create the following triggers to a "Calculate" Button
1. Subtract PercentBodyFat from Step1 and store back to Step1
2. Divide Step1 by 100 and store back to Step1
3. Assign the CurrentWeight to Step2 (I didn't want to change the value of CurrentWeight as I might want to use it elsewhere)
4. Multiply Step2(CurrentWeight) by Step1 and store back to Step2
5. Divide Step2 by 0.8
6. Set IdealWeight equal to the value of Step2 (Don't really know why I did this...I could have just used IdealWeight in place of Step2)
7.Reassign 100 back to Step1 so I can re-enter new values and recalculate if the user wants.
Everything works fine and I get the values I want...just wonder if there are any short cuts or best practices when doing calculations.
6 Replies
No, you are doing this correctly. There are no real shortcuts to this.
Just remember that trigger order is important and will be executed from top to bottom.
Thanks Magnus. I would love to see additional examples of how folks are using calculations if anyone cares to share!
Bret, I find I am doing a lot more calculations via a javascript triggers. especially for age or when I need to vaildate the entries
Phil, You just went way over my head with javascript triggers...I love Articulate Presenter and Storyline because I have no real programing background. (I'm a veterinarian!). Where can I learn more about javascript? Is this something I should even consider or is it pretty complicated? Thanks for your help!
This is the great thing about storyline, it will grow with you, I will post a demo I did, if i can find it
I cannot find it, will keep looking but here is a starter http://www.articulate.com/support/kb_article.php?product=st1&id=llwes8cn32vg
This discussion is closed. You can start a new discussion or contact Articulate Support.