LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Connect a choice with a certain string-value

So here we are again 🙂

Now the problem is as follows: We want to be able to choose from the menu ring for each string. If one choose the same alternative on the menu ring for two or more strings the program shall show an error. Ex "you have choosed a port that is already choosen". Any tip or ideas?

Best regards.
0 Kudos
Message 1 of 12
(3,619 Views)
The basic question is how to search an array for duplicate values. One good algorithm for you would be:

1. Create an array of "canport" values by feeding the overall array into a For loop and unbundling the canport value by name inside and outputting those values
2. Use Sort 1D Array to sort the canport array
3. Feed this array into a While loop. Inside, use Index Array with the "i" counter to grab out each element in series. Use a shift register (initialized to -1) to store a value to compare with the array element. If equal, then the user has selected a duplicate item, and you can use this result to stop the loop and feed it out of the loop to trigger your user prompt. If not equal, then proceed to the next loop iteration, making sure to feed the indexed array element into the shift register for next time around.
4. Also feed the Array Size into the While loop so that you can stop the loop if the iteration counter reaches a value of one less than this array size; this halts the process in the case that there were no duplicate entries.

I'm not sure why someone rated your question with one star, other than perhaps because you've asked a lot of questions in the past. This isn't a topic that comes up on this forum ten times a day or anything. Maybe someone thinks you should take a LabVIEW training class (a worthwhile investment); I've described your solution instead of programming it in order to help you practice your programming and ultimately understand better.

Take care,
John
Message 2 of 12
(3,586 Views)
Hello!

Yes we know that we are not good in LabVIEW. We would like to take a class in LabVIEW if we had the possibility. But if one do not want to answer our scream for help then don´t. We are sorry but we did not know that this forum is only for those who knows about LabVIEW. We ask question to learn but maybe the questions are on a low level.

We thank you for your help with this thing anyway 🙂 The thing when one initializes the shiftregister stopped us unfortunately. We do not know why and how to do this. Should we do this in combination with the comparision or how do you mean? The value that comes out from the menu ring is the value of the row, right? Can one compare this in some way... of course if you do not want to answer there is no need 🙂

Thank you. Best regards
Message 3 of 12
(3,568 Views)
Hello,

I think that a trainning would be good for you, or at least taking some time to understand it's basic functionalities before starting to build a complete program... but you're right in the fact that if people don't want to answer, they allways have the choice not to answer instead of giving you that ratting.

Back to your question: Initialising the shift register is giving it the value it will have in the first iteration of the loop. What you must do is connecting a value to it from the left side, i.e., from outside the loop.

Hope it helps,
If you still have questions, don't hesitate to post them, for sure someone will help you...

Paulo
Message 4 of 12
(3,564 Views)
Hello!

Yes of course 🙂 The problem we had was why to initiate it to -1 in this case... when one initialize a shiftregister one use an array and then a constant in it, right? But then inside the loop there becomes problem because that it is an array and out from the index array there is an element... thank you for your nice answer by the way 🙂 Best regards.
0 Kudos
Message 5 of 12
(3,555 Views)
Hi,

What John told you in his previous message was to feed your data array into a while loop and then check if you have repeated values in it.
So, the use of the shilt register is to store values from the previous iteration in order to compare them with the value of the actual iteration - the array is sorted, so if you have repeated values they "next to each other".
What I mean is that your shift register must be a number and not an array... Create it and then conect a number to it from the left with -1, and then, inside the loop use the "i" to index your array and compare it with the previous element (that comes from the left shift register) and connect the actual value to the right shift register so it will be available in the next iteration.

Try to do it yourself, if you can't say it, I'll post an example...

Paulo
Message 6 of 12
(3,551 Views)
Hello again!

Yes now I tried. I know that is something with the index? I send my VI... what am I doing wrong? Yes that is good to practice myself of course 🙂 Thank you again for your help.
0 Kudos
Message 7 of 12
(3,545 Views)
Hi,

Here it is changed for you...
It works as I told you before, the shift register keeps the value from the last iteration, so you can compare it in the next one and what you have to compare is array values, so it must be a value, not an array...
I added a comparision with the size of the array to stop the loop in case of non repeated elements.

Hope you learned how it works,
Paulo
Message 8 of 12
(3,541 Views)
Hello !

Yes that was something that I tried myself in fact, 🙂 but it did not work completely for me... Because the problem was that it went outside the arraysize when it encountered in the array. Thank you very mutch for your help 🙂 I have learned a lot today because of your help 🙂 *smile*
Message 9 of 12
(3,540 Views)
You're welcome, I'm glad you learned how it works,
Regards,
Paulo
Message 10 of 12
(3,532 Views)