Skip to main content
Participant
Dec 2, 2014 4:11 PM UTC
Answered

Problem with incrementing variable with html5 output (Captivate 8)

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.
Lilybiri
LilybiriCorrect answer
Legend
Mar 3, 2016 5:49 AM UTC

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
Oct 8, 2018 6:28 PM UTC

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.

Translate
TLCMediaDesign
Inspiring
Oct 9, 2018 1:30 PM UTC

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);

}

Translate
Participating Frequently
Oct 9, 2018 4:26 PM UTC

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.

Translate
Quest5639
Known Participant
Mar 5, 2016 5:22 PM UTC

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.

Translate
Lilybiri
Legend
Dec 2, 2014 4:57 PM UTC

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.

Translate
Participant
Dec 3, 2014 2:51 PM UTC

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

Translate
TLCMediaDesign
Inspiring
Dec 12, 2014 3:39 PM UTC

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.

Translate