Hi Craig,
The help file of the scan from string is effectively wrong and misleading.
As I use LV to manipulate a lot of strings, I have discovered the use of
[^character] to scan for a string until I find a specific character.
Look at the attached example VI.
Also, don't forget the "Spredsheet string to Array" function which is very
useful to parse a string containing data separated by the same character
(like a coma or a tab).
Regards
-Michel Farhi
"Kevin B. Kent" wrote in message
news:394009E3.95625B0A@usa.alcatel.com...
> Craig Graham wrote:
>
> > I've just run into difficulty using the "Scan from string" function to
parse
> > a long-format date, and on investigating discovered the examples aren't
too
> > reliable either. If I use the first example, which is the string:
> >
> > abc,xyz
> > 12.3+56i 7200
> > .
> > and the format string %s,%s%f%2d
> >
> > then the function returns an error 85: Scan From String was unable to
> > convert the input string into the datatype indicated by the format
> > specifier.
> >
> > NI knowledgebase has nothing that looks relevant.
> >
> > Although I've gotten around it by using the "Scan string for tokens"
> > function, this would have been a more elegant way, so I'm curious to
know
> > what could have gone wrong- or if it could be some bizarre bug recently
> > introduced. The function works fine with a mix of strings and numbers,
and
> > only seems to fail where you try and scan two strings seperated by a
comma.
>
> Craig,
> Indeed the example given is incorrect and misleading in more than one way.
> In order for that example to work the format string must be "%3s,%s%f%2d"
> Also in the example the 3rd output is actually 12.3 +56.0i IF you set the
> indicator to be CBD (complex double) the last output should be 72 (not 7).
>
> Here is the reason for this.
> The function kinda pre evaluates the input string. The abc,zyx is a string
> so the function pops the whole thing off (Meaning the first output is
abc,zyx).
>
> There is not a string left for either the ',' or the zyx. The next thing
in
> line is
> the 12.3+56i. This is known to be a number so the string conversion fails
and
> you get the error 85.
> Putting the 3 in front of the first "s" tells the function to take only 3
> characters
> so that the rest of the conversion works.
>
> The scan from string is a very powerful function but it does take some
time
> to get used to it's operation.
> If you want you can send me the string and I will send you the format
string to
>
> parse it out.
> Kevin Kent
>
[Attachment scan example.vi, see below]