04-01-2010 08:15 PM
I have a two dimensional array filled with information about consumer food products. I want to allow the user to remove a particular item that they choose from this array. The problem is that my user interface only allows them to enter the item's barcode number. So in this array in column index 2 is the items barcode number. The program I have now works well if there is only 1 item of a particular barcode number, but doesn't work well if there are multiple items in the array of the same barcode number, say for example 3 bottles of mountain dew, because it just removes the first row that it comes to with the matching barcode in it. So what I am trying to do is search this array by way of barcode for all instances of that barcode. Then display to the user the entire row of data for every instance of that barcode and then allow them to select the particular row that they want to remove from the array.
Any help would be greatly appreciated. Thank you.
Solved! Go to Solution.
04-01-2010 08:22 PM
04-01-2010 08:33 PM - edited 04-01-2010 08:35 PM
04-01-2010 09:13 PM
04-01-2010 09:25 PM
I don't have any examples. It is just one of those things where you figure out what you want to do, possibly create a flowchart or write some pseudocode, then just code it.
It would be easier if you attach what you have done so far, then it becomes possible to improve upon that.
04-01-2010 10:57 PM
This is what I have come up with so far. It successfully finds a particular item, but only if it is the first item on the list or row index 0. If I try to find another item say further down the list like at row indexes 6,7 and 8, it will not find them at all. What this is doing is searching each row and then if it finds the barcode I was trying to write to a new array at the same row index as the item was located.
It also will not find all of a particular item if say mountain dew is on row index numbers 0, 1, and 10. It will only output 0 and 1 but not 10. So it looks like my code doesn't do empty space at all. If you see anything I can do, please let me know. What I have is intriguing but I realize it still has some problems to fix.
04-01-2010 11:02 PM
04-01-2010 11:04 PM
Please send the actual VI. Not a supersized, but impossible to read screenshot.
Make sure you have some actual data saved as defaults in the controls.
04-01-2010 11:23 PM
04-02-2010 09:29 AM - edited 04-02-2010 09:30 AM
This should get you a couple steps closer.
Inside your case structure, don't use insert into array. Use build array to build your array of items to remove. Insert into array is the wrong function to use probably 99% of the time. Your method fell apart if you picked the wrong item. You don't want to insert the 8th item in the master array into the 8th position of the empty array. You can't because everything up to that position is undefined.