FieldPoint Family

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I code a lookup table from a combo box

Hi, I am trying to use combo boxes on a front page which selects a desired gas.  I then want this to look up a simple 2D table which returns the associated K factor value to be used.  Essentially I need to gain the conversion factor for a selected gas to be used in the block diagram to adjust the outputs and inputs accordingly.  I tried to load an excel file into an array and then extract the desired numeric value but failed. Any help would be great.  I don’t want to be manually inputting the values in the block diagram because there are lots of them so it must be read in from a file of some sort.

 

Regards

0 Kudos
Message 1 of 2
(3,036 Views)

Hello Sniepsy,

 

You posted this question in the FieldPoint forum, but the question appears to have nothing to do with that hardware product.  I can’t deduce from your post what programming platform you are using, but I assume that it’s LabVIEW.  If so, you might consider reposting your question to the LabVIEW forum.

 

I’ll broadly address your question though.  If the number of possible input factors is small (say in the order of less than 50), the easiest thing to do is just generate 2 1D arrays with one for keys, and one for values.  Make sure the indices match up and just look up the index of a key in array 1, and index array 2 with that to get your number.  A purist might complain that the lookup time would be linear, and we can achieve log-time with sorted lists and advanced structures – but since these aren’t in LabVIEW the overhead of implementing them might outweigh the benefit.

 

Hope this helps!  Please let us know if you have further questions.

Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 2 of 2
(3,030 Views)