LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong use of "Scan From String" function in a while loop?

Hi,

I've got a "Scan From String" function inside a while loop. On the first iteration it converts correctly the number passed by the input string (for example 4) But on the second one it has only spaces (one or more \s) as input string.
I expected to obtain a zero as output (as it does always that it can not make any conversions, as I am supposed to) but indeed, i subtracts 1 from the previous number (according to the number indicated as example I would obtain a 3 as output)

What's wrong with this?
Does the function fails on this case?

The rest of the diagram o the VI is expected to manage a 0 on that situation, like others in which the conversion is not made.

Andres.
0 Kudos
Message 1 of 6
(3,071 Views)
I tried reproducing your problem but haven't had any luck. If you attach your code, I can take a look at it for you.
0 Kudos
Message 2 of 6
(3,071 Views)
I have simplified the VI evading calls to other VIs and trying to reproduce the mistake.
The type of string I introduce to reproduce the mistake is:
clock 3 (30) clock (40)

Forgetting to introduce a number between the second "clock" and the following parenthesis, I would manage it programmatically with code that isn't included.
Then "Scan From String" is supposed to do not make a conversion. But it leaves a 2 as output (in this example)

I have realised, unbelievable but true, that it has matter with the number I substract to the output number (if it were 2, I would obtain 1 as output and so on)
Excluding that, I got the conversion made before as output, 3, on the second time that "Scan From String" executes. But, how can this func
tion as bad?

I am using LV4 on an old PC. I have tried to reproduce it with LV6 and it works. But it isn't desirable for me, I would have to convert a lot of VIs and surely I will find a lot of errors due to the conversion (I have already tried)
0 Kudos
Message 3 of 6
(3,071 Views)
I understand your concern about converting code frome one version to another, still it's not as bad a process as you might imagine. The main thing is to resist the temptation to try and convert your entire application in one go.

I'm not sure what you mean by "errors due to conversion" as the conversion itself shouldn't cause errors.

How big is your application?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 6
(3,071 Views)
I was able to reproduce your problem in LabVIEW 4. It has been fixed in current versions of LabVIEW. I have attached a VI that illustrates a workaround for this problem. It basically checks to make sure a number is indeed in the string before passing the string on to the "scan from string" function. This workaround should solve the problem if you want to continue using LabVIEW 4. Of course, I would definitely recommend upgrading your code to a newer version of LabVIEW as well.
0 Kudos
Message 5 of 6
(3,071 Views)
Thanks Matt,

I think it will help very well.

I wish I could upgrade as you both said. Surely, with a little pattience it won't be as bad. Even though, despite my desires to change, I still continue to have my work done with LV5 which I expect to have soon at home, forgetting LV4 at last!
0 Kudos
Message 6 of 6
(3,071 Views)