04-19-2024 07:25 AM
Nice, the graph works well, the final thing is that I need to fix the array with "good answers" and "wrong answers" : I have no error but it's always 0.
04-19-2024 07:51 AM
@ElixirDaSueños wrote:
Nice, the graph works well, the final thing is that I need to fix the array with "good answers" and "wrong answers" : I have no error but it's always 0.
That array is initially empty.
So, you're replacing an element that doesn't exist with a new element. (2X).
The result is an empty array.
Why not keep it simple:
To replace this (but now working unconditionally):
Also, right click on constants and controls\indicators to change their types. Some numbers are float, some are integer. That shows as orange and blue. If the types don't match, you get the red coercion dot. That's ugly and almost always a code smell (a sign something's off).
04-19-2024 08:16 AM
Your graph is only showing 1 data point because your build array function is only an array of 1 point. You need create a shift register using an array not just a single number. Then add to that array. I know its hard to explain so I'll fix your VI (just for this case), but you really need to understand how to build arrays so they accumulate values.
This is only building an array of 1 point every time.
This adds the value to an array of the previous values.This is accumulates the values.
04-19-2024 10:45 AM
It's perfect, the graph works well thank you.
The array works better now but still, it resets the "correct answers" count where there is a "wrong answer", I can't find why.
I added a timer that works, but only refresh why an action is made, how to get it refreshed every second for example ?
Thank you.
04-19-2024 10:57 AM - edited 04-19-2024 10:57 AM
First of all I would delete the sequence frame and the other event structure you put in. You don't need them and they just complicate your program. Just wire the errors together and then wire into the while loop. This will make the 2 property nodes execute before the while loop. This is LabVIEW's dataflow concept.
04-19-2024 11:02 AM
Yes, but it's part of my homework, my programm must contain a sequence...
04-19-2024 11:09 AM - edited 04-19-2024 11:16 AM
OK then you can leave it but remove the while loop and event structure in it. Just have the property node that sets the visible to True. Remove the one that sets it to false. It'll work out just fine.
The timer does not work because you have no timeout case in your main event structure. Add it back in by right clicking on the event and selecting Add event case. Then choose <Application> and select Timeout. Finally right click on the hourglass in the corner of the event and select create constant. This will create -1, which means the event case will never timeout.Change the number to something like 100 which means 100msec. Now the loop will update every 100ms and your timer will work.
04-19-2024 11:32 AM
And lastly the problem with the Array resetting to zero is because the case statement has unwired terminals which means a 0 is used when that part is run.
You will need to create another shift register to keep track of the Wrong Answers. Hope the pictures help.
04-19-2024 11:43 AM
Oh, yes. I think it should work better now, but since I added the timer who works : score, array and graph all stopped working correctly ? The score stays at -1 whatever the results
04-19-2024 12:13 PM - edited 04-19-2024 12:21 PM
Remove the while loop and event structure in the first part of the sequence. Two event structures in a program is tricky and should not be done. Just one of the quirks of LabVIEW. You can keep the sequence but just have the property node that sets to true.
Also this is my fault for forgetting but you have to wire the shift registers across in the Timeout case because they are getting reset to 0 when that part is run. And also you are missing the wire for the Wrong Answer shift register in the Ask a Question case. It also needs to be wired across. Can't leave them unwired because 0 will be used in the shift register.