LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

search

Solved!
Go to solution

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.

0 Kudos
Message 1 of 16
(2,697 Views)
The array type is String.
0 Kudos
Message 2 of 16
(2,696 Views)
You'll have to do your searching in a while loop, and stop the while loop when your search does not find anymore of those items.  Build a new array that you display that contains those items and also some sort of index value.  That way whichever they pick out of that array, you know which index value to remove out of the original array.
Message Edited by Ravens Fan on 04-01-2010 09:35 PM
0 Kudos
Message 3 of 16
(2,690 Views)
is there any sort of example that  you could show me. My program searches and the output is the row and column of the match, then i use the row number to remove the item. If there is no match the output of both row and column are -1. The search is in a loop but I guess I just don't know how to drop out when I have searched all of the way through the array.
0 Kudos
Message 4 of 16
(2,673 Views)

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.

0 Kudos
Message 5 of 16
(2,669 Views)

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. 

0 Kudos
Message 6 of 16
(2,653 Views)
Sorry I sent the wrong file, this one is correct.
0 Kudos
Message 7 of 16
(2,651 Views)

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.

0 Kudos
Message 8 of 16
(2,648 Views)
here is the portion that I am working on, as the default I have items set into the Current Items Array. I hope this will run for you, let me know if it gives you any problems.
0 Kudos
Message 9 of 16
(2,638 Views)

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.

Message Edited by Ravens Fan on 04-02-2010 10:30 AM
0 Kudos
Message 10 of 16
(2,620 Views)