Skip to main content
Participant
July 10, 2014
Question

Variables and Values

  • July 10, 2014
  • 3 replies
  • 396 views

Good afternoon everyone!

I am working with some variables in advanced interactions and have hit an issue I was hoping someone could help me with.

I am trying to get the variables to display 0.00 using conditional actions. If V_cost is = 0 assign V_cost 0.00 (want the 0.00 to be the displayed value in the box). When doing a calc on the variable of V_costa - V_costb and it equals 0 it won't display as 0.00 even

though the 2 variables are decimal+2 places after it. I was hoping that I could assign it as above if the result was 0 but it didn't work.

Also, some of these are values defined within the variable assignment, others are entered by the learner at run time. can I use the "literal" of these to even manipulate like I am above to use calculations on?

I am using Captivate 7

This topic has been closed for replies.

3 replies

Legend
July 11, 2014

I just saw that you were using Captivate 7.  For Cp 7, try this code for swf published output:

document.Captivate.cpEISetValue('m_VarHandle.V_cost', decodeURIComponent('0.00%03'));

Legend
July 11, 2014

Try this:

If  V_cost is = 0 then Execute this JavaScript in the current window

window.cpAPIInterface.setVariableValue('V_cost', decodeURIComponent('0.00%03'));

The %03 is the encoded version of an ASCII end of text (ETX) device control character (an invisible character).  For SWF output, it lets the ActionScript know where the end of the text should be.  For HTML5 output, you never see it.  The decodeURIComponent() function takes the %03 and converts it to a real ETX character (the non encoded version).

It would be really nice to have the ability to type our Captivate user variables as strings or numbers... but at least we have JavaScript to overcome such limitations.

RodWard
Community Expert
Community Expert
July 11, 2014

Captivate doesn't give you any real options to control decimals on numeric variables. I think you'll find that even if you put the number in as a literal with the decimals behind it Captivate will cut off the zeros anyway.  But you're welcome to try.

This is an area where Captivate could get a lot better.  Your alternative is to learn how to use JavaScript to perform these calculations and use your Advanced Actions to execute the JavaScript code.  Jim Leichliter has a good course on using JavaScript in Captivate.

Shawn1068Author
Participant
July 11, 2014

thanks Rod, that is what I was afraid of I am not sure if I am ready to tackle JS yet LOL.