06-19-2013 04:41 PM
ElectroLund,
Glad to hear that's working for you. I think the programmatic approach might be best for ensuring correctness every time, and it makes the code a bit more portable if you decide to change the UIR later. If you do run into any more issues with the control arrays, please let us know.
07-27-2013 04:32 AM
HI
I found the example for how to use the control array.
now i wanna to set each control attribute,cannot find the CVI function?
something like :
SetCtrlVal(panelHandle, GetCtrlArrayItem(ctrlArray, i), i%2);
setctrlattribute(GetCtrlArrayItem(ctrlArray, i),attr_label_text,"MyTest")?
Regards
07-27-2013 04:49 PM
Hi papaya,
it is better not to add to a closed thread that has little reference to your actual question. In your case you would better have started a new thread.
Regarding your question, you are only missing the panel handle variable in your sentence, like in every Set / Get of control values or attributes:
SetCtrlAttribute (panelHandle, GetCtrlArrayItem (ctrlArray, i), ATTR_LABEL_TEXT, "MyTest");
Alternatively, you can use the proper control ID:
SetCtrlAttribute (panelHandle, PANEL_NUMERIC, ATTR_LABEL_TEXT, "MyTest");
07-29-2013 08:38 PM
HI
Thanks for helping.
Now other problem:how to reset The CTR Counter?
I use the CTR0 to count outside events,after reading the CTR0 channel value, i wann reset the Buffer?
int32 DAQmxReadCounterU32 (TaskHandle taskHandle, int32 numSampsPerChan, float64 timeout, uInt32 readArray[], uInt32 arraySizeInSamps, int32 *sampsPerChanRead, bool32 *reserved);
Regards!
07-30-2013 01:53 AM
(...)
it is better not to add to a closed thread that has little reference to your actual question. In your case you would better have started a new thread.
Please open a new thread for this arguments: it has completely nothing to do with the original one!
01-10-2014 02:58 AM
This problem we also have been facing. We find that control array gets messed up when new controls are added to the panel after creation of control array. Sometimes, though random, editing of some properties of controls in control array also changes the order. We have to ensure that orders are intact whenever UIR gets changed. Sometimes the process becomes difficult when the UIR is quite complex with many panels/tabs/multiple control arrays.
Fixing up the control array in the code may not be always possible, if the number of elements are many(in which case, we have to refer to each control's name and add) and also when the UIR gets changed(during development cycle). (We also cannot assume that the required controlIDs are assigned sequential numbers).
It would be good if somebody could look into this problem and provide a solution.
01-10-2014 06:22 AM
It seems that at present the only viable solution is to handle the control array programmatically as suggested by Daniel.
What you could do to simplify the matter is to create an array of control IDs and use that array to generate the control array when you need it. Something like this:
// Configuration function at program start ctl = calloc (20, sizeof (int)); ctl[0] = PANEL_CONTROL1; ctl[1] = PANEL_CONTROL2; ... ctl[19] = PANEL_CONTROLN; // When loading the panel ctrlAry = NewCtrlArray (panelHandle); for (i = 0; i < 20; i++) { InsertCtrlArrayItem (ctrlAry, panelHandle, ctl[i], -1); }
Not so elegant a method perhaps but working, fast and it does not rely on z-plane sequence so you can treat non-consecutive controls.
02-24-2021 05:28 PM
After many years, I had an epiphany on this question of mine! Though Roberto's and others' programmatic solutions are the most guaranteed method, I found a way around this using only a UIR-based control array.
Selecting controls and adding them into a control array remains somewhat random in order:
But this doesn't matter! As long as you then change the tab order of the controls so that each control array item is in the order (index) you want, finding them in the code will then be in order.