LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String Indicator displays wrong results

Solved!
Go to solution

Hello, I have a homework assignment and I am facing few problems with the string indicator.

What I'm assigned is:

The user fills 2 arrays with 5 numbers

Then the user clicks on th FILL button and the program checks if the created elements in array 3 matches elements in array 1 and 2.

(I attached the doc file for clarity).

The string indicator gives wrong answers sometimes. (is there a better way to solve the string indicator?)

 

Thanks.

 

the vi is version 10.

Download All
0 Kudos
Message 1 of 5
(2,804 Views)

You need to put your result string in a shift register in the For loop. As written the only value you get is the result of the last comparision. You need to update and add the result to the string (if necessary) every iteration of the For loop. A shift register will allow you to do this.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 5
(2,800 Views)

Yeah I noticed that.

I changed it but there is a problem with the enters.

Isn't there any better solution for such a problem?

I have changed the range from 0-2

0 Kudos
Message 3 of 5
(2,789 Views)
Solution
Accepted by topic author A.A.A.

Better is what way? Not placing the extra blank lines in the string? If that is the case you should only update the string when necessary, not every iteration of the loop. If you mean something else I don't know what you want to improve.

 

There are quite a few things that can be improved from a coding perspective. When you wire an array to a For loop it is best to use auto indexing to determine the number of iterations the loop will run. Barring that as in the case of your first loop you should use Array size to determine the number of iterations to run, not a constant value. Your second loop can be simplified and does not require the array. Use a shift register and negate the value of teh Boolean every iteration. Also, the logic in the thrid frame would be easier to understand if you used an Or rather than an And. If any value is True check the arrays. Your actually have reverse logic. While it is correct it is the opposite of what someone would be thinking. Another method would be to add the two results and wire the numberic value to the case structure. Case "0" means everything is acceptable. The Default case (anything not 0) means you have unacceptable values.

 

One last comment would be what is actually your stop condition? The two nested while loops looks rather strange and unnecessary.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 5
(2,778 Views)

Hi, I noticed the errors and changed them. 
The loop stops when all numbers are acceptable; else  it will comtinue when FILL is pressed.

 

0 Kudos
Message 5 of 5
(2,763 Views)