LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Scan From String" and > symbol

I want to scan time from string like "10>20>30" (12 hrs, 20 mins and 30 secs). I cannot build proper format string. For "10_20_30" format "%<%H_%M_%S>t" would work but it is impossible to include ">" symbol instead of "_". I tried to screen it with backslash ("%<%H\>%M\>%S>t") but it doesn't work neither.

 

Another funny stuff with scanning time values. If I have string "10_20_30" and try to scan with "%<%H____%M_%S>t" or "%<%H_sdfdf__%M_%S>t" format string, everything works while I would rather expect "LabVIEW:  Scan failed. The input string does not contain data in the expected format." error.

 

The reason I try to scan such freaky strings is that I want to write a routine to scan an arbitrary data from string; I wanted to split the format strings into several one-scan parts scanning each part into the appropriate type Variant with "Scan From String" routine. To do this I need to figure out proper rules determining format specifier boundaries. I can develop my own rules conforming with my applications (surely the examples above are extremely freaky) but I thought its better to mimic "Scan From String" behaviour.

 

Are there any strict official format specifier rules?

 

PS: I work with LabVIEW 2011.

0 Kudos
Message 1 of 4
(3,375 Views)

Try escaping with the % character (I can't test myself right now):

 

%<%H%>%M%>%S>t

 

0 Kudos
Message 2 of 4
(3,364 Views)

Funny enough, it works. And the same strange behaviour (as in case of underscores or other symbols) exists: even if I have "%<%H%>abc%>%M%>%S>t" format string, it scans "10>20>30" as 10 hrs, 20 mins, 30 secs, "forgetting" excessive symbols in delimiter (so in case of "%<%H%>abc%>%M%>%S>t" format string it

 

  • will read "10>20>30", "10>ab>20>30", "10>>20>30" or "10>abc>20>30" correctly,
  • will read "10>>>20>30" as 10 hrs, 0 mins, 20 secs leaving current position at last ">",
  • and will not read "10>abb>20>30" or "10>ac20>30").

Very strange behaviour. It would be good to find official rules or just develop my own for my own routine as the last example really seems quite weird.

0 Kudos
Message 3 of 4
(3,358 Views)

pyatachyok a écrit :

Funny enough, it works. And the same strange behaviour (as in case of underscores or other symbols) exists: even if I have "%<%H%>abc%>%M%>%S>t" format string, it scans "10>20>30" as 10 hrs, 20 mins, 30 secs, "forgetting" excessive symbols in delimiter (so in case of "%<%H%>abc%>%M%>%S>t" format string it

 

  • will read "10>20>30", "10>ab>20>30", "10>>20>30" or "10>abc>20>30" correctly,
  • will read "10>>>20>30" as 10 hrs, 0 mins, 20 secs leaving current position at last ">",
  • and will not read "10>abb>20>30" or "10>ac20>30").

Very strange behaviour. It would be good to find official rules or just develop my own for my own routine as the last example really seems quite weird.


That make sense but it is not obvious.

First it searches a match for %H

Then it will try to match >abc, Partial possible matches are >, >a, >ab and the complete match >abc. Since these are not time format they will not modify the result ( any other combination will throw an error: >b, >abb, ...)

It will then search for the next match : > and then for a match to %M

It will then search for the next match : > and then for a match to %S.

 

Look at the case 10>>>20>30

10 matches %H

the first > matches partially %>abc (the scan position is now here: 10>|>>20>30)

it now look to match the %> before %M  (the scan position is now here: 10>>|>20>30)

It now try to match %M but the next character is > so there is no match (return 0) (the scan position is still here: 10>>|>20>30)

It now try to match the %> before %S  (the scan position is still here: 10>>>|20>30)

It now try to match %S and find 20  (the scan position is still here: 10>>>20|>30)

 

There is no more things to match in the format string so >30 is returned in the remaining string output of the Scan From String function.

 

Ben64

Message 4 of 4
(3,334 Views)