Explore the community Forums Lectora Lectora Questions & Answers Very Simple guide to using variables Reply To: Very Simple guide to using variables

#369367 Score: 1
Profile photo of Darrel Somoza
Darrel Somoza
Member
contributor
friend finder
beginner
intermediate
junior moderator
advanced
wise owl
curious george
profile
209 pts
@Klaatu

In this example the participant must click each button once before the next button is enabled allowing passage to the following page.

In order to do this we need to have a way of monitoring if a button gets checked. I set up a separate variable for each button, naming them btn1, btn2 and btn3. Because we only need to watch for two states, clicked or unclicked, I decided to use Boolean values true/false. I made the initial value of each of the btn variables false to denote that they have not been clicked.

Next we have to modify the variable when the button is clicked. This is done by adding an on click action – modify variable – set btn1 to true. Do this for each button making sure you modify the correct variable for each button (ie: button2’s variable is btn2, etc.)

Finally, we need to check to see if each btn is true, meaning they were all clicked. This is done by adding another on click action to each button (3rd action). This action says to enable the NEXT button ONLY IF btn1 = true AND btn2 = true AND btn3=true.
So, if you examine the actions for “Button” you’ll see:

OnMClkShow – Shows the initially hidden text box witht the 1 in it.
OnMClkModVar – sets btn1 to “true” (no quotes).
OnMClkSetState – Checks all three variables, one at a time, to see if they are all “true”. If they are then the NEXT button becomes enabled.

This post has received 1 vote up.
Attachments:
  1. variables.zip