LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

the user can go to next only if he answered the first question

Solved!
Go to solution

Hello dear all,

I'm coming back to you, I want on my interface that the user can go to next only if he answered the first question.
Can you help me please?
0 Kudos
Message 1 of 5
(881 Views)

There are two ways to do what you want- the "quick and dirty" way and the "right" way.

 

The quick and dirty way to do it would be to disable the Next button with an Enabled property node (right click->create Property Node). Each time in your loop, check to see if Answer has changed. If it has, enable Next until it's clicked again. That lets you keep the "general" flow of your program, but I wouldn't recommend it as it will be harder to do that in the long run than updating it to the right way.

 

The right way to do it is to use what's called an Event Structure. Use Help -> Find Examples to see some good examples of how to use them.

 

Basically, you want to respond to an Event- that is, a user clicking something. An Event Structure lets you do that. It will also get rid of the fact that your current loop spins as fast as possible (a "greedy loop") which isn't good. At the very least, you should add a "Wait" function of 50 or 100 ms in there.

 

An Event Structure will change your whole program to be event driven and you won't be free-wheeling the loop.

 

Also, I'd recommend not using a ring or enum for your index. Just use a regular number.

0 Kudos
Message 2 of 5
(853 Views)
Solution
Accepted by topic author Emilie_23

You could initialize your array with a sentinel value that is not a valid answer (e.g. -1) and only enable "next" if the value is non-negative.

 

 

altenbach_1-1674768334066.png

 

Message 3 of 5
(847 Views)

Hi @altenbach, 
Thank you very much 🙂
Have a nice weekend

0 Kudos
Message 4 of 5
(799 Views)

Hi BertMcMahan,
Thank you also 

0 Kudos
Message 5 of 5
(798 Views)