Skip to main content
Inspiring
August 26, 2015
Answered

How can I append two values together?

  • August 26, 2015
  • 2 replies
  • 695 views

I am using the advanced action:

Expression:  variable1 = variable1 + "1".

I would like Captivate to append the "1" to the previous value of variable1, not add them together.  So if variable1 started out as 154, after the expression is executed, it should be 1541, not 155. 

Is there a way to append numbers together?

Thanks for any help!

This topic has been closed for replies.
Correct answer ryan schar

Hello,

It seems to be working now in HTML5, actually.

I am using Adobe Captivate 8.

I have the (conditional) advanced action  "Expression: var1 = var1 + 1" attached to a click box.  (The condition is simply "1 is equal to 1".  I have been using only conditionals so that the advanced actions are as flexible as possible.  That was a tip from RodWard. : )  )  The original value of var1 was left blank.

I have a text caption on the screen with the content of "$$var1$$".

It seems to work in HTML5.  The first time I hit the click box, a "1" appears.  The next time, it's "11", and so forth.  It does not work like I want it to in swf.  In swf, the first time I hit the click box, a "1" appears. The next time, it's "2". 

Incidentally, I see the same behavior in HTML5 and SWF whether I use 1, the number, in the expression, or "1", the string.  It doesn't seem to matter.

2 replies

ryan scharAuthorCorrect answer
Inspiring
August 26, 2015

Hello,

It seems to be working now in HTML5, actually.

I am using Adobe Captivate 8.

I have the (conditional) advanced action  "Expression: var1 = var1 + 1" attached to a click box.  (The condition is simply "1 is equal to 1".  I have been using only conditionals so that the advanced actions are as flexible as possible.  That was a tip from RodWard. : )  )  The original value of var1 was left blank.

I have a text caption on the screen with the content of "$$var1$$".

It seems to work in HTML5.  The first time I hit the click box, a "1" appears.  The next time, it's "11", and so forth.  It does not work like I want it to in swf.  In swf, the first time I hit the click box, a "1" appears. The next time, it's "2". 

Incidentally, I see the same behavior in HTML5 and SWF whether I use 1, the number, in the expression, or "1", the string.  It doesn't seem to matter.

Lilybiri
Legend
August 26, 2015

No it does not matter because Captivate makes no difference between numbers and strings. It is just superfluous to add quotation marks if the literal consists of one word or one number. For a similar reason I will not use a conditional action when a standard action is doing the trick; because it means that the system has to evaluate a condition unnecessarily. With the present features where copy/paste is so easy within the advanced actions dialog box...

Lilybiri
Legend
August 26, 2015

Which version do you use? And for which output? There was a problem with HTML5 output in the first version of 8 for this kind of Expressions, not in SWF.

Expression works perfectly, but why do you put the literal 1 between "?

    Expression variable1 = variable1 + 1

Moreover in your example I would use

    Increment variable1 with 1

Want examples of expressions?:

Display Time information - Captivate blog

RodWard
Community Expert
Community Expert
August 26, 2015

Lieve,

He doesn't want to add the numbers together so as to increment the value.  He wants to concatenate the numbers so that they are placed side by side as if they were letter. 

So it's not 1 + 1 = 2 he wants. It's 1 concatenated with 1 = 11.

Legend
August 26, 2015

You can try the trick mentioned here. Haven't tried it myself. So not sure if it still works.

I Came, I Saw, I Learned...: Adobe Captivate 4: Gimme Some Space!

Sreekanth