LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to connect input string value to numerical values

Solved!
Go to solution

Hello,

 

I am trying to figure out how to connect a single user's input string value to numerical values. Basically I want the user to input the name of a gas that I have a list for (I believe i put the list of gasses in an array>). Then I want to match 2 numerical values "a" and "b" depending on which gas name the user has put in. These "a" and "b" values will be automatically matched with the gas name from a list I put. For example the gas hydrogen has a value of 3 for "a" and 4 for "b. so when the user puts the name "hydrogen" in a string constant, automatically  "a" and "b" should be outputted. I will be connecting a and b to a formula

 

Thanks for any help

0 Kudos
Message 1 of 9
(3,629 Views)
Solution
Accepted by topic author student11

Hi,

 

maybe it is not exactly what you are looking for, but maybe you could use enumerated data type and the array of clusters of the items (a, b).

 

Look at the VI I have attached.

Duri
0 Kudos
Message 2 of 9
(3,617 Views)

Didn't quite understand all of your problem description but I think you are looking for the Decimal String to Number VI in String > Number/String Conversion palette.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 3 of 9
(3,613 Views)
Solution
Accepted by topic author student11

It sounds like you want to take an input of a String type and search through an array to determine which element it is and then extract more information as a result.

 

You can search an array and get the element returned.  If you want to contain more information, you can look at a 2D array or an array of clusters to retrieve the 'a' and 'b' values, whatever they're supposed to be.

 

Of course, this is going to require a bit of work to build the array constant manually.

 

What is the homework problem you're working on actually asking for?

0 Kudos
Message 4 of 9
(3,606 Views)
Solution
Accepted by topic author student11

student11 wrote:  These "a" and "b" values will be automatically matched with the gas name from a list I put. For example the gas hydrogen has a value of 3 for "a" and 4 for "b".

This sounds a lot like an Enum to me.  Make sure you type def the enum to make sure updates quickly and easily make it to all copies of the enums.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 9
(3,589 Views)

This is exactly what I am looking for thanks. The hw assignment wants a user input to type a gas name, then it goes into a formula (a and b values depending on user input in string for gas name). Then of course an output value from the formula is formed.

0 Kudos
Message 6 of 9
(3,572 Views)

I am sorry I have a quick question. I understand this is an array constant. I can't figure out how to put the a and b values like you did here. How did you label these number constants in this array as a and b and grouped them together like this? Any help is appreciated.

 

asdfasdfsdf.png

0 Kudos
Message 7 of 9
(3,556 Views)
Solution
Accepted by topic author student11

 

Hi, try this. Hope it helps.

 

how to make constant.png

Duri
0 Kudos
Message 8 of 9
(3,543 Views)

That is perfect thank you so much.

0 Kudos
Message 9 of 9
(3,485 Views)