Trouble in Numeric Entry Variables and Sum

May 05, 2022

Trying to recreate a simulation of an excel calculator. I need multiple fields to add up to a sum and be able to be revised. 

I figured out how to make it happen but now something weird is happening with the variables. 

The way it is now I have the regular set variable [numericentry] to typed value when numericentry loses focus. I then zero out the sum variable in order to do a clean calculation then have a series of add triggers on object loses focus to do the calculation (not ideal but it should work). 

But when I run it it doubles the value. I took a look at the usage of VariableSum and for some reason it added another trigger behind the scenes to set VariableSum to the typed value. It's clearly not one I added so I can only assume that this is a glitch. 

Any ideas on how to bypass this or do the sum a different way?

4 Replies
Marcus Nielson

So far, I've solved this by changing the trigger to be "when X variable changes." That did the trick after I created a new slide. It still duplicated the first value even after the change. I figure it must be a very persistent artifact.

I also had to have a conditional stating that it would only add a value if it was greater than 0. This got around Storyline having 0 operate as a string instead of a number and the sum returning NaN.

Still open to hearing more elegant ways to create a sum calculation without a button to trigger the calculation.

Jose Tansengco

Hi Marcus, 

Thanks for sharing your project file with us!

I noticed that your slide had redundant triggers which were causing the entered value in the numeric entry field to double when activated.

I edited your project file to remove the redundant triggers, and this appears to have fixed the sum function of your slide. I've attached the edited version of your project file for your reference. For the edited version of your project file, you'll need to click out of the numeric entry fields in order to trigger the summation. 

Let me know if this works for you!

Marcus Nielson

Hey Joe, 
Thanks for your help. 

I appreciate that it works but I still don't understand why. The first trigger should set the typed value while the one you disabled should be adding that value to a different variable. Why does it do add Numeric Entry to VariableSum automatically?

Jose Tansengco

Hi Marcus, 

You'll notice that your slide has two 'Add variable' events assigned to each of your Numeric Entry objects. What's happening is whenever the focus is lost on any of the numeric entry objects, the two Numeric Entry objects are checked for values and then added to the 'VariableSum' variable. Basically, two values are being added to 'VariableSum' each time the focus is lost on the Numeric entry objects.