# LabVIEW

Showing results for
Did you mean:

Solved!

# Converting String Array to Integer string

I have two text files with numbers (signal1.txt and signal2.txt). I want to convert them to Integer array and have a process on them. When I converted them by Fract/Exp String To Number control, it shows just 0 (You can see in the attached file). How can I have the correct numbers?

Message 1 of 22 (713 Views)

## Re: Converting String Array to Integer string

[ Edited ]

Well your converting the numbers properyl.  That isnt the problem.

You get the 0 everytime because you are doing the "process" on the 0 index of your array every iteration, which happens to be zero.  I would consider doing away with the case structures and putting the process in a for loop for the smaller array size of iterations.  Then i would index my array based on the iteration of the for loop.

 if youre attempting to only do the addition when elements are present in both arrays, labview will only do the process on the smallest array, it does not assume 0 when there is no element present.

Hope that helps.

Regards,

Matt
Message 2 of 22 (692 Views)

## Re: Converting String Array to Integer string

Your two converted arrays look just fine to me.

I'm wondering what you are trying to do in the 2nd frame of your sequence structure.  There you are just indexing out element 0 of both arrays repeatedly.

Message 3 of 22 (689 Views)

## Re: Converting String Array to Integer string

Looking at the code, I get the impression that you are new to LabVIEW.

I suggest that simplify your problem statement.

You might want to focus on how to properly read a file in the first place.

From what you are trying to do, LabVIEW developwers have already done it for you in examples. At least in piecewise chunks. You just need to dig in a bit.

Take a look at the examples provided in the detailed help.

You should find some clues on what you need to do.

I have no idea what you are trying to do in your process, but it looks overly complicated.

Once again the examples can help you here as well. Look up array manipulation.

--good luck

Engineering - The art of applied creativity  ~Theo Sutton
Message 4 of 22 (682 Views)

## Re: Converting String Array to Integer string

I use the index zero to compare two elements in two arrays and based on some circumstances I remove the first element of each array (maybe one array is affected maybe both of them). Then I compare the element in index 0 again. It means I should compare the first element in each iteration. This matter is continuing till at least one array becomes empty. When I try it with an ordinary array it works but when I use a converted one it does not work and I guess removing items from a converted array is impossible. Please look at the new code and let me know your ideas. Thank you in advance.

Message 5 of 22 (672 Views)

## Re: Converting String Array to Integer string

Thank you. BTW please look at the attached file. It is explained and the complete code.

Message 6 of 22 (669 Views)

## Re: Converting String Array to Integer string

• Your sequence structure has no purpose, delete it.
• Decimal string to number would be more correct for intergers.
• You can wire the "default" and change the datatype to get exactly the integer flavor you want, no need to convert later.
• Read delimited spreadsheet would eliminate most code on the left. Set it to transpose and get the first row (i.e. first column after transposition) and you are almost there.
• Your pyramid of case structures makes very little sense. The top and bottom array size never changes in the shift register, so why do you think you need to measure it with every iteration? What do you actually want to do? I am sure there is a solution that takes less than 10% of your code.
Message 7 of 22 (667 Views)
Solution
Accepted by topic author Mmehrabin
‎09-23-2016 03:02 PM

## Re: Converting String Array to Integer string

[ Edited ]

Mmehrabin wrote:

• You don't need the middle shift register, just use a conditional tunnel.
• You don't need to chop up the top and bottom arrays. Operate in place and keep track of the current index.
• The latency control belongs before the loop so it can be folded for the duration of the loop. I am sure it will (and should!) not change between two iterations, right.
• Most of your boolean logic is baloney makes no sense. For example "=0 AND >0" will always be false!
• Why is there a 2s delay in the loop? Just for debugging?
• Are you sure the number wired to N is correct? I would think you a running out of elemens way before that.
Message 8 of 22 (663 Views)

## Re: Converting String Array to Integer string

In each iteration, I remove an element from array1 and/or array2 so I should check their size.

Message 9 of 22 (661 Views)

## Re: Converting String Array to Integer string

[ Edited ]

Mmehrabin wrote:

In each iteration, I remove an element from array1 and/or array2 so I should check their size.

So why are you iterating NxM times? You'll probably run out of elements way before that.

Do you have a description or link for the algorithm you are trying to implement?

Message 10 of 22 (653 Views)