02-26-2010 10:09 AM
Need you guys to give me some suggestion on how to improve my code. See attached code and explaination below.
1. Read Regs Banks: output a 2d array that contain my data (read through modbus)
2. for loop: process the 2d array one row at a time. Each row of data contains different subset of data and the size for the subsets vary. In this particular case, you have one subset with 1 parameter, and 3 subsets with 2 parameters for each row. The subset will be combined and convert into another datatype.
3. Multi Conv: take the data (array of U16) and convert it to an array of variant that could contain values of different data type.
4. Then, I need to index the variant array and change each variant back to it corresponding data type. (need improvement)
5. At the end, the data are fed into a cluster and than a indicator.
I think I need some serious improvement on No. 4, but I want to ask your opinion first, since I want to hear some fresh idea.
Feel free to tear this apart.
Yik
02-26-2010 10:19 AM
Quick thing for #4.
You are taking the variant array and indexing off the same element (#0) 4 times and converting that. I'm going to guess that you don't want the same element 4 times but 4 different elements. Not that you can resize the index array function by dragging the bottom border downwards. If you don't wire in any indicies, you'll get elements 0 through 3. If you need some other index, than just wire in the appropriate constants.
02-26-2010 10:25 AM
Why didn't I think of that? I keep doing multiple index array for a while now Thx! What about the varient to data part?
Yik