LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

search 2D array

Solved!
Go to solution

All.

 

I have a 2D string array that is set up like a table that displays results to the user. I need to search the first column (Sample #). If it's there, I'll need to display a message box to the user telling them that this sample has already been tested.

 

How do I go about doing this?

 

Eric

Download All
0 Kudos
Message 1 of 10
(7,214 Views)

Your Q is not very clear!

If I got you right you have at least three choices:

1. Select the column you want to search in (Index array with only the column number specified, keep the row unconnected -> returns a 1D array. Search this for your target and proceed as required.

2. Change all rows in your 2D-array into a cluster of named elements, where the column you are searching is specified first. You get a 1D-Array of clusters, that can easily be sorted (sort 1D-Arry). Search this for your target and proceed as required.

3. It might be a good idea to search trhe results before addem them to your array.

 

Just my € 0.02!

Greetings from Germany!
--
Uwe

0 Kudos
Message 2 of 10
(7,196 Views)

You understood my question.

 

Just so I understand your first point, if I want to return the first column, do I wire 0 to the "disabled index (col)?

0 Kudos
Message 3 of 10
(7,184 Views)

No, nothing!

wiring any value would enable that index!

0 Kudos
Message 4 of 10
(7,182 Views)

Something like this?

 

Sorry, I'm not too familiar with searching arrays.

0 Kudos
Message 5 of 10
(7,157 Views)
Solution
Accepted by topic author BadAzzS10

@BadAzzS10 wrote:

Something like this?

 


Wire a "0" to the lower index to get the first column. Leave the upper index unwired. (Currently, you get the first row!).

You can wire the blue output directly to the case structure. Make one case "-1" and the other the default.

What''s up with all the local variables?

If you don't want decimal digits, use the integer version.

Your test could easily fail if the table has e.g. extra spaces or other things. How and where was it created. Does not look safe!

 

Message 6 of 10
(7,149 Views)

I know Local Variables are bad, but I'm taking a large program and adding some functionality to it with a quick turnaround time. The long term goal is to get rid of those since I read that these can lead to race conditions.

 

We're taking some data from a test stand (distance & force) and entering these into a 2D array with the first row being the column headings. I believe that the two images a couple of posts above will shed some light on the situation.

0 Kudos
Message 7 of 10
(7,128 Views)

 


@BadAzzS10 wrote:

I know Local Variables are bad, but I'm taking a large program and adding some functionality to it with a quick turnaround time. The long term goal is to get rid of those since I read that these can lead to race conditions.

 

I would not call it 'bad', bad dangerous and often 3rd best solution. They carry the risk of race conditions, especially when adding some functionality to larger programs. But if you take care they are not that bad for configuration and initialization data. That kind of smaller data that are set_once, but read multiple times. I use 'em for communication ports, device handles etc. in test stations with varying DAQ device types like different DMM types etc.

Locals and Globals also cost you some extra data copies and always run in the UI thread. This is OK for small datasets and rarely used data, but couts up with larger strings, arrays or huge clusters and when those are used very frequently (multiple times per second).

Just my € 0.02!

Greetings from Germany!
--
Uwe

 

0 Kudos
Message 8 of 10
(7,094 Views)

 


@LuI wrote:
Locals and Globals ... always run in the UI thread. 

 

No, this is incorrect. Quote from "In What Thread Do Local and Global Variables Execute?":

 

"A common misunderstanding is that local and global variable operations execute in the UI thread, or require a thread swap to the UI thread - this is not true." 

Message 9 of 10
(7,085 Views)

Oops, that happens when still mostly working in LV711.

Thx for updating me knowledge 😉

Greetings from Germany!
--
Uwe

0 Kudos
Message 10 of 10
(7,076 Views)