LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in vi

Hi
 
I have a vi that was prepared by Mr. Fung while my copy was accidently deleted.
 
Instead of producing 4 columns of data it only produces 2 columns of data. I have forgotten what i did in the original vi.
 
Can anyone help?
0 Kudos
Message 1 of 2
(2,328 Views)
Your problem is the fact that you have a variable number of space characters separating your values, and you are only cleaning some of them up. You actually don't get "only 2 columns", but many more, but quite a few values are zero. remember, your separator is set to \s, so if you have more than one consecutive \s you'll get extra zeroes.
 
Your code is way too complicated for such a simple task! A much better solution would be to use "scan strings for tokens". By default, empty tokens are not allowed, thus multiple separators are automatically contracted into one. We no longer neet to strip extra spaces!
 
We need to do it in two easy steps:
  1. Get each line using \r or \n as seperators (outer WHILE loop)
  2. for each line, get the four values, using \s or \t as seperators (inner FOR loop).
  3. To save memory, you can convert each value to DBL in the inner loop directly and form the array using autoindexing.

I have attached a VI showing this procedure (LabVIEW 7.1). It seems to work fine. I think you agree that it is simpler. 🙂

Let me know if you have any questions. Happy coding. 🙂

0 Kudos
Message 2 of 2
(2,318 Views)