10-19-2020 03:37 PM - edited 10-19-2020 03:47 PM
I have a 2D array of strings, I convert it to a numeric array, and then I parse it back with the for loop and use it that way. But my problem is that if the value added to the last index is equal to the new value entered from numerical control, I want the last index to be deleted, but I was not successful.
I researched many topics but could not find exactly how to do this. Is there anyone who can help with this?
ideas on this topic are really valuable.
Solved! Go to Solution.
10-19-2020 03:41 PM
Hi worker,
mind to write English thread titles to your English message text?
@constructionworker wrote:
I have a 2D array of strings, I convert it to a numeric array, and then I parse it back with the for loop and use it that way. But my problem is that if the value added to the last index is equal to the new value entered from numerical control, I want the last index to be deleted, but I was not successful.
There is no numeric control in your image.
There is no VI we can work with - we still cannot debug images in LabVIEW…
What is the "last index" for a 2D array?
What's wrong with DeleteFromArray when you want to delete an element?
(Btw. you don't delete indices from an array, but elements!)
10-19-2020 03:49 PM - edited 10-19-2020 04:28 PM
I am very sad. There was an error.
10-19-2020 04:11 PM - edited 10-19-2020 04:29 PM
Assuming I am not understood, I want to repeat my question. I don't want the added values to be repeated.
For example, the arraye could be 1-2-3-1, but not 1-2-3-1-1-1.
10-19-2020 07:07 PM - edited 10-19-2020 07:08 PM
Wouldn't it be easier to just not add it to the array if it is the same as in the previous iteration?
What is the purpose of all this? If you just want to add values after they have been changed, use an event structure.
On a side note:
10-19-2020 07:22 PM
It seems you probably want to prevent the array from filling with millions of rows per second (because you loop has no wait!) and there are much better ways to do that (e.g. an event structure as mentioned).
Still if you want to keep polling, here's a simple draft. Yes there are better ways to solve your problem once you define the problem better. 😉 You also need to decide if the values entered before running should be added or not (hint: initialize the feedback node with e.g. NaN)
Please explain how this part of the code fits into the rest of your code
10-20-2020 03:19 AM
I'm trying to make this code part of a big program. The numbers added need to record without repeating because it's making a list.
After adding conditions for 2 variables this way, it became really informative for me. This way my problem was solved. Since there are so many values attached to the function, I wanted to constantly check if the value has changed. Functions always work at the same time, they need to control different values. But if I put a function on hold, the other functions wait for it, I can say that the case structure method is best suited for this. To add values to a new array, if the same variables are added to the array continuously, the program may be exposed to a lot of unnecessary data and crash. Since adding the repeated values does not change anything, I did not want the renewed values to be added so that the program does not have to be added so that the program works without enough effort.
altenbach Thanks for your ideas and your efforts. It was really an idea opener.
10-20-2020 03:55 AM - edited 10-20-2020 03:58 AM
Please do NOT attach a VI with the same name as my attachment. If you modify a VI, give it a new name!
If you want to make sure that both values have changed before adding a row, just do the checking on the array. Much less code. (make sure to set the comparison mode to "compare aggregates"). You could even make the control an array with two elements. Now you don't need to change the code, even if you want five controls in the future!
If you place indicator terminals inside case structures you need to ensure that they don't contain stale data from the previous run. You can set "VI options...execution...clear indicator when called" To make sure they don't retain stale data. My solution was to place the table terminal before the case structure. This way it is guaranteed to clear when the VI is run. Why do you think you need to convert to string and back to DBL for the "element" indicators? Just use a 1D array as indicator and wire it to the orange array as in the picture above. Don't overcomplicate things!
Why do you think you also need the "appended array" indicator. Its data is identical to the table, so only one of the two is needed.
10-20-2020 10:25 AM
Thanks. As you said, I added the elements directly to the array instead of using string arrays considering your suggestions. Now everything is fine. The table didn't need it, I got rid of it. I am grateful for your help.
10-20-2020 03:10 PM - edited 10-20-2020 03:37 PM
As a general rule, please cleanup your code: