06-25-2010 02:44 PM
Hi all,
I am having several problems with case structures at the moment. I want to have 8 control where the user selects a number on each control and I would like these controls to become the values on the case selector dropdown. I am wondering if this is possible or if there is a way to get this done.
Thanks.
06-25-2010 02:55 PM
I can think of a few ways to get this done, but before the craziness ensues let me ask you a couple of questions.
What is the range of these 8 numbers?
Do you realize that even if it is 0 or 1 you are looking at 256 different cases? How many unique cases do you expect?
06-25-2010 02:58 PM
The range is from 0 to 200, although the controls will each take one number. And there are only 8 cases as those are the only numbers I am looking for. Hope that makes sense.
06-25-2010 03:11 PM
I am starting to get there. You have 8 controls which can have values between 0 and 200. Do you want to do something 8 times with those different values, or are there 200 things you could do, but only want to do the 8 that are in the list? I am not seeing where the case structure enters.
Step 1. I would consider using an array (or at least a cluster) for the 8 controls.
06-25-2010 03:52 PM
I have a spreadsheet and I am going to use two columns. One column has all the 8 numbers in about 100 rows. The other column is filled with random numbers. I would like to make 8 arrays, and each array is associated with one of the eight numbers. So, I am feeding in the column of 8 numbers to the question mark on the case structure. I would like my case structure selections to have those 8 numbers and based on which of the eight numbers is being read at the time, the program will extract that value and place it in one of the arrays. The reason I would like to have controls is because these 8 numbers will change depending on the spreadsheet and they're not always the same constants, so the use of a control is necessary here.
Does that explain my question in more detail?
Thanks.
06-25-2010 04:12 PM
Just wire the numeric control into the case selector. Like this:
You can edit the 0,Default field. You can put a single number (like 1 or 2), or you can put a range of numbers:
0..3 means all numbers between 0 and 3 including 0 and 3.
0.. means all numbers greater than or equal to 0.
..10 means all numbers less than or equal to 10.
You can combine: 0,2,4..10 means a match on numbers 0 or 2 or 4 through 10.
Put whatever code you need inside each case. Click on the case border to add new cases, then edit the number at the top.
06-25-2010 04:16 PM
The input to the question mark is coming from an array, and I'm not worried about that. I'm just worried about customzing the case selector dropdown and I would like it to have 8 options and each option associated with a control that the user inputs at the beginning of the program.
06-25-2010 04:42 PM
You can't wire an array into the question mark. Your explanation is not very clear. Can you give us an example? How does the user select a control? Then once selected, what exactly is fed into the question mark? Is there an array of controls and the input to the question mark would be the index number of the select element in the array?
06-25-2010 04:54 PM
This example is not exactly what you are looking for, it is just the closest thing I had on hand. When I am faced with a similar task I tend to sort on the first column and then extract the subarrays. I use an array of clusters because the arrays are usually of different lengths. The advantage of sorting is that you do not have to know a priori what the 8 (for example) values in the first column are.
This snippet sorts a 2 column array (in this case both columns get sorted so it is slightly different than your case I assume). The while loop extracts chunks with the same value in the first column. The output is an array of clusters, one element is the common first column value, the second element is the array of column 2 values.
06-25-2010 04:58 PM
The column from the spreadsheet containing all the 8 numbers repeated several times is indexed into the question mark. The case structure is located inside a for loop repeating based on the number of rows we have. It reads the first row, sees which control from the user it is matching (in this case, the case selector) and then performs the operations based on that case selection. Therefore, I would like to have 8 cases. However, I don't want my cases to be constants because the row of 8 numbers differs from each excel file. Instead, the user will type in the 8 numbers in the 8 controls on the front panel at th beginning of program execution. The program does not run until the user has typed in all 8 numbers and presses done so they can get out of the for loop and the program execution takes place. Those controls I would like to become case selector values. I'm thinking that i will need to create an array of those 8 numbers after user input, but how can i input it to the case selector values. That's where I am lost.
Thanks.