09-15-2010 11:50 PM
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
Solved! Go to Solution.
09-16-2010 12:30 AM
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
09-16-2010 01:04 AM
Hi Muthuraman,
Ya Mike is correct. see the image file to implement the same in VI
09-16-2010 01:05 AM
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
09-16-2010 02:44 AM
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
09-16-2010 02:45 AM
Hi Muthuraman,
see the attached image please, this will work.
Mike
09-16-2010 02:52 AM
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
03-20-2012 11:29 AM
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.
03-20-2012 11:32 AM - edited 03-20-2012 11:35 AM
03-23-2012 11:36 AM
Error 85 appears to be a warning.
Is it possible to suppress it?