Copy link to clipboard
Copied
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?
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I downloaded de patch on that page : Adobe - Adobe Captivate Support Center : Downloads. And re-published. Still doesn't work.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Did you publish again and Force republish all slides? It works perfectly for me in 8.0.1.242.
@TLCMediaDesign it was a bug in 8.0.0, and it didn't really matter if you gave the variable a default value of 0, at least not for me.
Copy link to clipboard
Copied
I think this bug is back in Captivate 9. All I've done is assign 0 to a variable and incremented in by 1 numerous times. When I put it in output I'm getting a string of 1's. Lilybiri‌
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Unfortunately I am still running into this issue. I am using expressions in advanced conditional actions. (I want people to calculate VAT depending on which codes they use - if that makes sense). The whole training is build around people being able to test and see the result. But now nothing is working. I am really at a loss of what to do.
It all works fine when previewing in project, previewing in browser, but it does NOT work when previewing in HTML5. All the variables have a default value of 0, so that workaround doesn't appear to do the trick anymore.
I am on CP 9 version 9.0.1.320.
Copy link to clipboard
Copied
There's been another update to Captivate since your version.
Maybe you should get that update.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
@TLC made a little typo, something very easy to do (the voice of long experience here!).
var getMonth = Number(window.cpAPIInterface.gerVariableValue("cpInfoCurrentMonth"))+6;
should be getVariableValue instead of gerVariableValue
Does that solve the problem?
Copy link to clipboard
Copied
I did catch that and fixed it, but still not nothing populating in those variables.
Copy link to clipboard
Copied
Can you try the script again. I fixed my post with the catch the dan56​ found, as well as a missing closing paren in the last statement.
Unfortunately I cannot paste anything into a website, blocked at my work, so I have to type all of the scripts.
Copy link to clipboard
Copied
With that closing parenthesis, and adding an "else" for future dates that do not cross into the new year, it works!
I'm definitely going to hang on to this code for the future. Thank you!
var getMonth = Number(window.cpAPIInterface.getVariableValue("cpInfoCurrentMonth"));
var getYear = Number(window.cpAPIInterface.getVariableValue("cpInfoCurrentYear"));
if (getMonth > 12)
{
window.cpAPIInterface.setVariableValue("duedatemon", getMonth - 12);
window.cpAPIInterface.setVariableValue("duedateyr", getYear + 1);
}
else
{
window.cpAPIInterface.setVariableValue("duedatemon", getMonth);
window.cpAPIInterface.setVariableValue("duedateyr", getYear);
}