LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sort numbers seperated by a comma into an array

Solved!
Go to solution

The attached VI should accept the two numbers, seperated by commas, and then use the first number to set a boolean in an array. Then the next number should set the corresponding array location with the value.

 

For example,for an array of 5 elements:

User input is 3, 2. The VI would produce the following two arrays: 

 

F 0

F 0

T 2

F 0

F 0

0 Kudos
Message 1 of 16
(3,968 Views)

Separated

 

When you post your VI, please save it with some typical data saved into the controls as defaults so we can run it right a way, and truly understand how your input data is formatted.

 

Take a look at this.

 

 

Message Edited by Ravens Fan on 03-18-2010 08:02 PM
Message 2 of 16
(3,957 Views)

Cool,  Thanks for the help and I'll do a better job of detailing my posts. 

The picture you posted worked but only for one set of values.  I want to sort a set of values that will change everytime I call this VI.

 

So a set of values will be:

One call to the VI may have: 

3,2

4,1

8.4

 

Another call may have:

1,3

2,2

 

Another call may have:

1,1

 

Another call may have:

1,2

4,1

5,2

6,3

 

etc....

 

I have updated my VI and have gotten close but I can't seem to capture the value after the comma in the array of numerics.  I hope I am explaining myself enough?

 

0 Kudos
Message 3 of 16
(3,928 Views)

You can use RavensFan's code exactly how it is.

Just change one little thing.

 

Where he has the 'row IDs....', instead of a string, you will have an array of strings.

 

Put the rest of the code, except for that input inside of a For loop.

When you pass the array into the For loop, it will run RavensFan's code and change all of the necessary elements.

Message Edited by Cory K on 03-19-2010 11:06 AM
Cory K
0 Kudos
Message 4 of 16
(3,921 Views)
That doesn't work.  I only get the first value in the row of ID's 
0 Kudos
Message 5 of 16
(3,916 Views)
Can you please show us what you are doing in your code?
Cory K
0 Kudos
Message 6 of 16
(3,913 Views)

You actually said user input is 3,2.  You never said anything about having multple combinations of these.

 

Post what you have done so far.

0 Kudos
Message 7 of 16
(3,896 Views)
I think you need to describe the problem you are trying to solve better as well. What is the data coming in? What does it mean or represent? What exactly does your final data mean and what should it represent?


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 8 of 16
(3,890 Views)

I have attached an update to the VI and did what Cory recommended.

 

Yes, my first post did not provide enough info, I am trying to rectify that here.

 

The purpose of the VI is to assign a boolean value to a series of valves.  These are rotary valves and require a pulse (1 then 0) to turn them to the next position.  Some valves have 4 positions, some have 3, and some have 6 positions.  I am using compact fieldpoint to interface to the valves.  So, I want to send a TRUE to the cFP channel that  is connected to one rotary valve then also send a number of positions to turn. Hence, the boolean and numeric array of clusters that this VI will produce.  Yes, the final version will combine the two arrays into a cluster inside an array... an array of clusters.

 

The valve or "row of ID's" text box will vary. I have a total of 8 valves and a maximum of 6 positions. Again some valves have only 3 positions, some valves have 6 positions, etc....

 

So, sending a 3,2  will ultimately wind up as rotary valve 3 turn to position 2.  A 4,1 will signify that valve 4 should be pulsed 1 time. A 1,6 shall turn valve 1 six times.

 

The user will input the string, (i.e. 3,2  4,1  8,5) and the valves 3, 4, and 8 should turn their respective position after the comma.

0 Kudos
Message 9 of 16
(3,878 Views)

I'll add something else,  my thought is that if I can get the two arrays to line up then I can run the two arrays in a for loop or while loop and if a TRUE value is seen then all I have to do is find the numeric value in the same location in the numeric array and that is how many pulses I send to the valve.

 

boolean array     Number array

3,2

F                                  0

F                                  0

T                                  2

F                                  0

F                                  0

etc...

 

4,2 5,1

F                                  0

F                                  0

F                                  0

T                                  2

T                                  1

F                                  0

 etc....

0 Kudos
Message 10 of 16
(3,875 Views)