LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scan from string not working.

Solved!
Go to solution

Hi All,

 

I am getting a string "a,b:c-d". A small need is to get a,b,c,d strings seperately using "scan from string". I tried format string "%s,%s:%s-%s". But scan from string is not working. string 1 = a,b:c-d; string 2, string3, string 4  are empty. I also get an error.

 

Is there any format string format i should follow to get a,b,c,d correctly using scan from string.

 

Regards,

Muthuraman S

Regards,
Muthuraman
0 Kudos
Message 1 of 11
(5,644 Views)
Solution
Accepted by topic author Muthuraman

Hi Muthuraman,

if you have only one character like "a" and "b" and so on, then it works with a fixed field size of 1. Otherwise you can work with replace string and split the string with the "spreadsheet string to array function".

 

Mike

0 Kudos
Message 2 of 11
(5,634 Views)

Hi Muthuraman,

 

Ya Mike is correct. see the image file to implement the same in VI

0 Kudos
Message 3 of 11
(5,619 Views)

No.

 

There is no restriction on the string length. The format is string1,string2:string3#string4-string5..... I know we can extract string 1, string 2, string 3, .... string 5 by usring match patttern and any other way (Which is round around method).

 

I was just thinking if i can extract the strings using only scan from string functionality. This way it will be very generic.

 

Your suggestions are welcome.

 

Regards,

Muthuraman S

Regards,
Muthuraman
0 Kudos
Message 4 of 11
(5,618 Views)

Your example is flawed, it sends "a,b:c:d". Changing that we can get to work. 🙂

You can use Scan from string, but there is a small pitfall. %s matches a full string, i.e. all writeable characters, thus including ,.;: and such. What you have to do is match a string apart from those characters.

 

This match string will solve the issue. Instead of matching a string, you match everything apart from ', : -' to get the separators.

"%[^,],%[^:]:%[^-]-%s"

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 5 of 11
(5,600 Views)

Hi Muthuraman,

see the attached image please, this will work.

 

Mike

0 Kudos
Message 6 of 11
(5,599 Views)

The main difference between Mike's and mine suggestion is that he's declaring which characters is allowed (in this case only english letters) while mine says which isn't allowed (allowing special characters and numbers apart from the delimiters). Both works.

 

/Y

 

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 11
(5,592 Views)

Difference between English and German version of LabVIEW 2011?

(1) English Version: The attached VI throws error 85 if the input consists of one string only

(2) German Version: The attached VI works fine if the input consists either of one or of more than one strings.

Reimar Spohr
0 Kudos
Message 8 of 11
(5,225 Views)

Hi Reimar,

 

as already answered in the German LabVIEWForum the German LV version also answers with errors when the string doesn't fit the format settings...

Best regards,
GerdW


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

Error 85 appears to be a warning.

Is it possible to suppress it?

Reimar Spohr
0 Kudos
Message 10 of 11
(5,185 Views)