Skip to main content
Inspiring
August 6, 2016
Answered

Variable on multiple pages - resolve with button

  • August 6, 2016
  • 3 replies
  • 408 views

Hi Folks,

Quick question. I think I know the answer to this but I thought I would check here.

Can you have input boxes (where students input numbers) on different pages and then use an expression linked to a button event on separate page to add add and sum the inputs? Basically,  can I have variables on different pages and resolve on another page altogether or do I need to have the expression and sum on the same pages?

Cheers

Steve

    This topic has been closed for replies.
    Correct answer Lilybiri

    No problem for numbers, not sure if you are also talking about concatenation of strings?

    Since Captivate has no functions, you'll need two Expressions to calculate the sum of three variables:

    Expression v_sum = v_one + v_two

    Expression v_sum = v_sum  + v_three

    3 replies

    Inspiring
    August 8, 2016

    Thanks Lilybiri, BDuckWorks and TLCMediaDesign for your assistance with this !

    BDuckWorks
    Inspiring
    August 8, 2016

    I believe the best practice would be to trigger an advanced action onExit of each slide, placing the contents of the TEB into a variable.

    IMHO, this will ensure the variable values are available, as the TEB would only appear from the slide. (You may be able to manage this differently if you set the TEB to be active for the entire project, and then hide and show it for the slides that they need to input.)

    Moderator: there are several bugs in this answer, please read the following answer for corrections

    Lilybiri
    Legend
    August 8, 2016

    @BDuckWorks Sorry to disagree and want to warn other users. There are several reasons for my disagreement:

    1. The On Exit event of slides is to be avoided, it cannot be trusted even if the last frame of each slide is visited. It will never fire if that last frame is not visited, which often happens when you have a Next button on the slide (or master slide)
    2. There is no reason to put the contents of a TEB in a variable, because each TEB has automatically an associated variable that is populated with the entry in the TEB in real time. Why do double work? Normally that associated variable has the same name as the TEB (which I don't like at all), but you can immediately replace it by a custom variable using the X button to the right of the TEB-variable field. That is why I used v_one instead of Text_Entry_Box_x
    3. There is NO way to have TEB to be timed for the rest of the project.: It IS an interactive object, and the only interactive object that can be used on master slides or timed for the rest of the project is my favourite Shape Button.
    4. The OP mentioned that he'll use a button to calculate the sum.
    BDuckWorks
    Inspiring
    August 8, 2016

    Thanks Lilybiri​ for your well detailed response, also TLCMediaDesign, I see my assumptions were incorrect.

    I'd had some early troubles with TEB functionality, so I'll revisit my understanding of them.

    Lilybiri
    Legend
    August 6, 2016

    A variable keeps its value until you have it changed, of course you can use those variables on any slide following the slide where they were populated. I don't know why you seem to think that variables are reset on each slide? Variables are only reset if an action occurs to reset them, like the Retake action for quizzing system variables, or if you leave the course and reopen it.

    Inspiring
    August 7, 2016

    Hi Lilybiri,

    Thanks for the note. I think I may have posited my question incorrectly. What I mean is, if I have a blank TEB variable on slide 3 and another one on slide 22 and say a  third on slide 37 and they are all connected by an Expression (that adds them all together) can I have an Event button on slide 40 that will add and display that number when it is clicked. I think the answer is probably yes but I just thought I would check here in case there were some Captivate programmatic exception I am unaware of.

    Cheers

    Steve 

    Lilybiri
    LilybiriCorrect answer
    Legend
    August 8, 2016

    No problem for numbers, not sure if you are also talking about concatenation of strings?

    Since Captivate has no functions, you'll need two Expressions to calculate the sum of three variables:

    Expression v_sum = v_one + v_two

    Expression v_sum = v_sum  + v_three