# Variables

Sep 14, 2014

By
Jin Hiya

Hi,

Can anyone please help me out? I was watching this tutorial video on "Adding Data Entry Fields" and one scene (at around 50 seconds into it) got me wondering how to build this particular slide using variables. This slide is set up so that if the user provides his/her information, the answer automatically gets worked out and displayed. Below is the link to the video.

http://community.articulate.com/tutorials/products/adding-data-entry-fields.aspx

I think I have two questions here. One is "how do you create radio buttons"? The other is "how do you set up variables to make it happen"?

Thank you for your guidance in advance!

## 4 Replies

Hi Jin,

That's one of my early favorite tutorial videos on variables because it demonstrates the calculation of combined variables.

Answer to your first question is to click the Insert tab > Buttons > Radio Button. These are pre-built radio button objects you can use to build custom interactions like the one in the tutorial.

Answer to your second question is more about design first. In Jeanette's example she's gathering input data on the user for "salary", "percentage of contribution", and "years to retire" for 401(k) and then calculating how much one would have contributed up to the point of retirement.

While I'm not familiar with Jeanette's logic in how she set this up, there's probably several ways you can accomplish it. Not working this out other than in my head as I type, I'm sure there's a more elegant way. For now, here's how I'd initially approach it.

We need some variables.

The slide is set up with a Data Entry Numeric Entry object for "Salary"

Three radio buttons which should all be in 'Button Group 1'

And a Data Entry Numeric Entry object for "Years to Retire"

The calculation happens when you click the "Calculate" button with a couple of triggers:

Again, probably a hundred different ways to do this, but hope this helps you get off on the right foot.

Kevin,

Thank you for your help. However, I cannot seem to put my brains around the variable part. Please have a look at the file in which I created a slide per your instructions except for the variables. I would appreciate if greatly if you could just set up the variables for me. I would then take a peek at them and that would help me comprehend how the variables work in this situation. Thanks a lot for your assistance in advance!

calculate.storyHi Jin,

Sorry for the delay.

First, a couple things to know about multiple calculations in Storyline.

Since we have to calculate "salary" by "percent" we need to store that calculation somewhere because we need that value to calculate by "years". Building this out I realized we need one more variable to store the second calculation in order to display "contribution" and to maintain the entered values. I refer to this as "Set & Pass." Meaning we

Seta variable by some calculation and thenPassit to another variable so we can later use it for more calculations. Also, my initial thoughts above about how to set it up did work, but working through it I found a better way than using conditional triggers.Note: you don't always have to do this but when displaying values on screen, you want those values to remain in tact while doing more calculations - that's why we Pass it to another variable.I noticed you set all the variables first based on my suggestion above...that's good. However, data entry objects will automatically create a variable as soon as you insert them on the slide such as: NumericEntry and NumericEntry1. These two objects are for Salary and Years so we simply rename the default variable name to a name we choose. Also, it's best to rename the object itself in the timeline to match so we keep things nice an organized.

Slide setup:Number Variables:Triggers:If you follow the logic of the triggers you'll see we're setting all our values by user interaction. Salary per user input, percent to calculate by which radio button is selected, and Years per user input are all in their respective buckets. Next we just pass the first calculation to a container variable and then use that container to calculate the next operation. Finally displaying our end result when clicking the Calculate button.

You can use this model for a number of different interactions that have three (3) input values.

Your file attached with the above explanation set up. Note that I put "listener" variables on screen so you can see when they fire.

Hope this helps.

jhiya_calculate.storyKevin,

Thank you for taking the time to help me out with this problem. I think I will need to experiment with the logic a little bit before I can fully comprehend it. Hey, I really appreciate your support!! Thanks!!

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