Math Related

This topic explains how to use all the CpExtra command variables related to math.

xcmndRandom

Parameters

  1. Name of Captivate Variable (the generated random number will be assigned to this variable)
  2. (optional) Highest number in random range.
  3. (optional) Lowest number in random range.

Description

This command variable will generate a random number and then assign that number to the Captivate Variable provided in the first parameter.

If only the first parameter is provided a random decimal number between 0 and 1 will be generated.

If the first and second parameters are provided a random whole number between 0 and the second parameter will be generated.

If all three parameters are provided a random whole number between the third (lower) and second (higher) number will be generated.

xcmndRound

Features

  1. Uses @syntax
  2. Uses comma delimited lists

Description

Assigning xcmndRound with the name of a Captivate Variable will cause the number to be stored in that variable to be rounded to its nearest whole number.

Examples:

  • 3.3 will be rounded to 3
  • 6.6 will be rounded to 7
  • 1.5 will be rounded to 2

You can also assign xcmndRound a comma delimited list of variables

Assign | xcmndRound with MyVar1, MyVar2, MyVar3

...Or you can assign it an @syntax range of variables

Assign | xcmndRound with MyVar@

xcmndRoundTo

Parameters

  1. Name of Captivate Variable (or @syntax range of variables)
  2. Number of decimal points that variable should be rounded to.
  3. (optional) String: Up or Down

Description

xcmndRoundTo will round the number in a variable to a certain number of places.

For example, lets say you have the variable MyVar which equals 6.6666666

Assigning the following...

Assign | xcmndRoundTo with MyVar, 2

Will change the value of MyVar to: 6.67

On the other hand, assinging with...

Assign | xcmndRoundTo with MyVar, 4

Would change the value of MyVar to: 6.6667

With the optional third parameter, you can designate whether xcmndRoundTo should always round up or down.

So the following code...

Assign | xcmndRoundTo with MyVar, 2, down

...would change MyVar to: 6.66

xcmndFloor

Features

  1. Uses @syntax
  2. Uses comma delimited lists

Assigning xcmndFloor with the name of a Captivate Variable will cause the number to be stored in that variable to be rounded DOWN to its nearest whole number.

Examples:

  • 3.3 will be rounded to 3
  • 6.6 will be rounded to 6
  • 1.5 will be rounded to 1

You can also assign xcmndFloor a comma delimited list of variables

Assign | xcmndFloor with MyVar1, MyVar2, MyVar3

...Or you can assign it an @syntax range of variables

Assign | xcmndFloor with MyVar@

xcmndCeil

Features

  1. Uses @syntax
  2. Uses comma delimited lists

Assigning xcmndCeil with the name of a Captivate Variable will cause the number to be stored in that variable to be rounded UP to its nearest whole number.

Examples:

  • 3.3 will be rounded to 4
  • 6.6 will be rounded to 7
  • 1.5 will be rounded to 2

You can also assign xcmndCeil a comma delimited list of variables

Assign | xcmndCeil with MyVar1, MyVar2, MyVar3

...Or you can assign it an @syntax range of variables

Assign | xcmndCeil with MyVar@

IF YOU LIKE WHAT YOU'VE READ ABOVE, THERE'S PLENTY MORE!

Join more than 2500 other Adobe Captivate users just like yourself and receive regular troubleshooting tips, illustrated tutorials, technical information, and creative solutions to real-world e-learning development issues. (See an example here.) Click the button below to join our community.  It's completely FREE!