LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scan From String - Data Within Double Quote

Solved!
Go to solution

Hi Folks,

 

Can you help me on getting the string out from (Send message “15 E 1 0 0 80 80 80 80 0 0 0 0 FF 0” to sim module)....?

 

I want to extract 15 E 1 0 0 80 80 80 80 0 0 0 0 FF 0 using Scan From String function. By the way, let me know, if there is any efficient method than using Scan From String function.

 

Thanks

 

0 Kudos
Message 1 of 11
(6,891 Views)
Solution
Accepted by topic author Blessing_Star

Do you simply want to remove the double quotes or are you looking to extract the numbers? If you simply want to remove the double quotes here is a VI that will do that.

 



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 11
(6,883 Views)

Thanks for helping me. I want to extract the Hex values those are inside the quote.

 

Input String = Send message “15 E 1 0 0 80 80 80 80 0 0 0 0 FF 0” to sim module

Expecting O/p = 15 E 1 0 0 80 80 80 80 0 0 0 0 FF 0

 

Appreciate your help. 🙂

 

Thanks

0 Kudos
Message 3 of 11
(6,875 Views)

Perhaps the code I posted here would be useful.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 4 of 11
(6,871 Views)

You can use Scan from string with the following format specifier:

 

extract hex data.png

 

the number of %x must match the number of hex values in the input string. If the value is not constant consider using a regular expression to extract the data. %[^"] will match any string characters up to the first double quote. The double quote in the format specifier must be the same as the one in the input string (I changed it in the example code).

 

Ben64

Message 5 of 11
(6,859 Views)

@ben64 wrote:

You can use Scan from string with the following format specifier:

 

extract hex data.png

 

the number of %x must match the number of hex values in the input string. If the value is not constant consider using a regular expression to extract the data. %[^"] will match any string characters up to the first double quote. The double quote in the format specifier must be the same as the one in the input string (I changed it in the example code).

 

Ben64


The one downside of this approach is that your input string must always a particular size. If your data can vary in the number of hex numbers you will get a more generallized solution using a loop will be required. This is essentially what the link that I posted earlier does.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 11
(6,853 Views)

Thanks for the help. If you look at closely, input string have quotes like this 13 E 1 8 0 80 FE 80 80 0 0 0 0 FF 0. Those quotes are quite different from this one ". I think, i may have to use these quotes as per the input string.

 

Thanks for all the responses.

0 Kudos
Message 7 of 11
(6,851 Views)

Yes, the quotes you have are different but the various solutions posted will work as long as you include the correct character(s) in the regular expression or scan from string format specifier.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 8 of 11
(6,839 Views)

Thanks to Mark & Ben for the responses.

0 Kudos
Message 9 of 11
(6,832 Views)

I was checking 'Unquote String (DQ).vi'. It has some limitations.

Look at the results:

imagen.png

Thanks.

0 Kudos
Message 10 of 11
(1,115 Views)