ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Obtaining variable values from string

So I have a shared variable string that sends something that looks like this:

"a = 1.0000E1
b= 2.0000E4 "

 

And so on. What function should I use to extract the number from a, so that I could read 1.0000E1?

0 Kudos
Message 1 of 15
(5,249 Views)

You could use "scan from string" and set the initial scan location at 3. If the string before the "=" can be longer, find its position and scan after it.

0 Kudos
Message 2 of 15
(5,230 Views)

If the input string is multiline, something like this will give you an array of variables and an array of values.

 

Scan from string.png

aputman
Message 3 of 15
(5,223 Views)

That is very close to what I am looking for!  What if my variables aren't just a-z, but long complicated names?  In the actual application, I have over 50, but I want to extract 5 of them, so could I just do %[var1,var2,var3,var4,var5] = %e in the search

0 Kudos
Message 4 of 15
(5,204 Views)

That returns a string that contains those characters.  If you want uppercase and/or digits, use "%[0-9a-zA-Z] = %e" as the format string.

aputman
0 Kudos
Message 5 of 15
(5,199 Views)

Using the same front-end as aputman, you may need to search on the '=' sign if variable names change in size and content.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 6 of 15
(5,195 Views)

So I am attaching what I have so far.  Say out of the variables, I want to only read a,c and variable_one.  And this is always known, but the values way change.  Can I have it so that it does that?  ie "[a,c,variable_one] = %e" ? 

0 Kudos
Message 7 of 15
(5,174 Views)

Use %s = %e

 

Ben64

0 Kudos
Message 8 of 15
(5,152 Views)

You will need to split string on '=' if the string in the opening thread is correct.  The variable name a is followed by a space where the next line with b has no space before the equal sign.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 9 of 15
(5,144 Views)

@ben64 wrote:

Use %s = %e


As long as there is a space between the name and the =, that will work.  If not, then use %[^=]=%e.  Personally, I would probably use the Match Pattern to find the = and then convert the After String (value) and keep the Before String (name).



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
Message 10 of 15
(5,139 Views)