Skip to main content
Participant
December 2, 2014
Answered

Problem with incrementing variable with html5 output (Captivate 8)

  • December 2, 2014
  • 17 replies
  • 2610 views

In my project, I increment a variable with 1 to count the clics.

In flash, it works fine, but in HTML5, it is adding 1....

Normaly: clic =1 clic =2 clic=3

HTML5: clic=1 clic=11 clic=111

Help?

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer Lilybiri

Are you using the Expression action?  If so, change to the Increment action.  Expression may be concatenating the numbers as strings instead of adding them.


Solution or workaround is to give a number as default value when defining the variable. It is fine to use '0', which allows Captivate to identify this variable as being a number. The issue is back but with an easy workaround, which was not possible in the previous version's bug.

Rod, it is not only happening with Expression but also with Increment.

17 replies

Participating Frequently
October 8, 2018

I'm experiencing this problem in Captivate 2017 (10.0.0.192)

My aim is to figure out the month and year will be six months in the future. Below is my Advanced Action to assign the variables (I've color coded the variables to make it easier to follow). My duedateyr works great (and I've tried different values in both decrementing and incrementing just to verify it is working). Unfortunately, duedatemon does not work when rendered in HTML.

                Execute Actions

Expression: duedatemon = cpInfoCurrentMonth + 6

Assign duedateyr with cpInfoCurrentYear

                If ( duedatemon > 12 )

Decrement duedatemon by 12

Increment duedateyr by 1

Today the current month is October, so I would expect my first expression to result in 16.

16 is indeed greater than 12, so subtract 12 and it should become 4.

It works in the flash preview, but in the browser the duedatemon returns 94.

I also tried making it two lines - "Assign duedatemon with cpInfoCurrentMonth" and then "Increment duedatemon by 6" but get the same incorrect results.

TLCMediaDesign
Inspiring
October 9, 2018

Try executing this JavaScript instead.

var getMonth = Number(window.cpAPIInterface.getVariableValue("cpInfoCurrentMonth"))+6;

var getYear = Number(window.cpAPIInterface.getVariableValue("cpInfoCurrentYear"));

if (getMonth > 12)

{

window.cpAPIInterface.setVariableValue("duedatemon", getMonth - 12);

window.cpAPIInterface.setVariableValue("duedateyr", getYear + 1);

}

Participating Frequently
October 9, 2018

Thank you for your code and help! I very much wanted it to work, as it looks much cleaner than the JavaScript option that I eventually came up with. Unfortunately, I must be doing something wrong to implement it.

I did come up with something that is working, so for now I need to move on with my work. But you have made me curious to learn more about "the Common JavaScript interface for Adobe Captivate." If there are some good lessons or videos that anyone can recommend, I'd like to study them in my free time.

Quest5639
Known Participant
March 5, 2016

I was using the Expression action and then tried Increment but was having trouble with both. Thanks for the workaround Lilybiri - that did the trick.

Lilybiri
Legend
December 2, 2014

I suspect you didn't install the patch, present release is 8.0.1.242 and this was one of the bugs that are corrected in the patch.

Participant
December 3, 2014

I downloaded de patch on that page : Adobe - Adobe Captivate Support Center : Downloads. And re-published. Still doesn't work.

TLCMediaDesign
Inspiring
December 12, 2014

Do you have the initial value set to 0 (zero). It's treating it as a string. Not sure how CP works and JavaScript does not have strict datatypes, but it may help.