LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI to search for specific character & check to be Integer

Hello all, i apologize if this has been asked before.

I have come up with a simple VI to grab specific characters from a string.

However I want to go 1 step further, which is to ensure that the characters are integers and not other characters.

I have no luck so far to get my VI to perform that extra task, so is there anyone who can advise me?

 

I have attached the current VI that I am using now.

Thank you.

JonKang

0 Kudos
Message 1 of 5
(2,982 Views)

|testres=[0-9]+ Verify FOE_Y  in value,

0 Kudos
Message 2 of 5
(2,968 Views)

The character that I am looking for is after the ","

Example: this is the whole string that I receive

BCNF|id=xxxxxxxxx|testres=8016 Verify FOE_Y in value,-4|testres=8017 Verify FOE_X in value,-2|

 

The 2 values I need to grab and verify are the '-4' and '-2'

So far I am able to get the numbers but I am stuck with the conversion between string & integer.

 

Thank you

0 Kudos
Message 3 of 5
(2,933 Views)

Hi Kang,

 

The 2 values I need to grab and verify are the '-4' and '-2'

Those values are missing in your example…

 

So far I am able to get the numbers but I am stuck with the conversion between string & integer.

Where are you stuck?

Your VI already contains a conversion from string to numeric data, but you aren't able to use this function???

 

I would search for "Verify" in your input string, then parse the next string to determine either FOE_X/FOE_Y. With the remaining string I would use ScanForString with "in value,%d"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(2,926 Views)

@KangJonathan wrote:

The character that I am looking for is after the ","

Example: this is the whole string that I receive

BCNF|id=xxxxxxxxx|testres=8016 Verify FOE_Y in value,-4|testres=8017 Verify FOE_X in value,-2|

 

The 2 values I need to grab and verify are the '-4' and '-2'

So far I am able to get the numbers but I am stuck with the conversion between string & integer.


Well, you didn't say you want to grab them. You only mentioned search and check...

 

Use Decimal String To Number to convert the string to integer.

 

But why not use a Scan From String? It's much cleaner and safer then two match patterns. The format string would be:

 

BCNF|id=%[^|]testres=%d Verify FOE_Y in value,%d|testres=%d Verify FOE_X in value,%d|

 

That would give you a string, and 4 integers (extract the bottom to 5 outputs):

BCFN|id= matches the literal string

%[^|] matches anything but |

testres= matches the literal string

%d matches any integer

Verify FOE_Y in value, matches the literal string

%d matches any integer

|testres= matches the literal string

%d matches any integer

Verify FOE_X in value, matches the literal string

%d matches any integer

| matches the literal string

0 Kudos
Message 5 of 5
(2,918 Views)