Working with StoryLine Variables Operators

Variable in StoryLine are fantastic. I have used them to create drop boxes and perform many different types of calculations and need to go beyond the standard add, subtract, multiply and divide in manipulating the variables. In the sample attached, I have made all of the normal calculations without any problems. However, I need to perform the following calculation: rvol^-.552 .... that is rvol variable to the -.552 power. It does not appear that I can perform this within StoryLine. Can this action be performed outside StoryLine on a variable exported from StoryLine and then imported back into StoryLine with the results?

4 Replies
Michael Hinze

You could try a JavaScript and use the Math.pow method to calculate the value and then pass it back into Storyline. Here is a potential issue: If your Storyline variable is a Number, the result of the calculation will be truncated to two decimal points. If your Storyline variable is Text, the result will be untruncated, but you can't use that text variable for further calculations. See here a quick example (and the source file is attached) that shows the two possible results in red (see upper right corner) on the Calculate layer. Also, I noticed in your publish settings that you enabled HTML5 output and the Mobile Player option. JavaScript is not supported with the Mobile Player App.

Joe Jones

Thanks. I created an similar app for android using JavaScript with that exact Math.pow calculation, but I don't know how to use JavaScript with StoryLine to pass the results back. I perused the source file you provided but could not determine how you did the calculation in JavaScript and passed it back. Any hints?

Also, I have many results (which need to be used in calculations) between .053682 and .000948 numeric values. I may need to divide my variables by 100; do my calculations; and multiply by 100 to get accurate answers.

Besides the need to multiple decimal point values, I would like to also have integer outputs. Is there a way to define an numeric variable as an integer ... again, I could use JavaScript to do this if I can see how they 'hand-shake'.

It sounds like my project will not be compatible with iOS equipment ... that was the reason I was trying to get this into StoryLine. Any other solutions besides JavaScript that might work???