Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Adding numbers in separate boxes

Enthusiast ,
Jul 28, 2016 Jul 28, 2016

Hi Folks,

Not sure if Captivate can do this or not but what I want to do is. Add numbers from three different boxes that will create the total in a fourth separate box. Can Captivate do this with Advanced Actions or Math Magic?

Any help would be greatly appreciated!

Cheers

Steve

887
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 28, 2016 Jul 28, 2016

Yes you can do this using the Expression action in a Standard or Conditional Action.  It allows you to perform simple math such as addition, subtraction, multiplication and division.  Values entered into Text Entry Boxes are automatically stored in user variables (usually given the same name as the TEB).  You can use these values in Advanced Actions to perform math with Expressions.

If you have a need to perform more complex math you may need to consider using JavaScript instead.  Advanced Actions are still quite limited in this regard.

The MathMagic plugin that comes with Captivate is really more about creating an image of a formula or equation that you need to use in your project.  It's not a tool for performing calculations at runtime.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 29, 2016 Jul 29, 2016

To add to Rod's answer, if you only want to make the total it is pretty easy. But you'll need a 'trigger', an event to launch the advanced action that will calculate the total (maybe a 'Sum' button) by launching this advanced action:

  Expression v_sum = v_one + v_two

  Expression v_sum = v_sum + v_three

The variables v_one, v_two and v_three are associated with the three Text Entry Boxes (I prefer not the use the default variables, you can create immediately a custom variable using the X button next the variable field). The variable v_sum is another variable that had a default value of 0. You have to display that variable in a text container (caption or shape) using the other X button in the Character part of the Properties panel of the text container:

XButton.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 30, 2016 Jul 30, 2016

Hi Rod and Lilybiri,

Thanks for this information! So it looks like I can achieve what I want to do in a couple of ways, either using Advanced Expressions or using Javascript. I have another question.

Once the sum has been arrived at say 2 + 1+ 3 = 6 can I then have (using javascript or conditional variables) take the number 6 and place it into,  and have it displayed, in one of 4 new boxes that are based on a range of numbers. For example 1-3, 3-6, 6-9, 9-12. Since the number is 6 it would land in the second box. 

Does that make sense? If so what would be the better choice Advanced Actions or Javascript?

Cheers

Steve

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 30, 2016 Jul 30, 2016

Either method would do but if you don't know JavaScript then use Conditional Advanced Actions.

You'll need one decision block in the conditional action for each of the four break groups.  You'll also need a different User Variable for each group since you are going to be displaying the result in a different Shape or Caption depending on where the value falls.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 30, 2016 Jul 30, 2016
LATEST

Perfect ... thanks Rod!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources