LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

control array element order changing

Solved!
Go to solution

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.

0 Kudos
Message 21 of 28
(1,807 Views)

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

 

 

0 Kudos
Message 22 of 28
(1,779 Views)

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");



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 23 of 28
(1,771 Views)

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!

 

0 Kudos
Message 24 of 28
(1,743 Views)

(...)

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!



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 25 of 28
(1,732 Views)

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. 

0 Kudos
Message 26 of 28
(1,612 Views)

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 27 of 28
(1,606 Views)

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:

 

ElectroLund_0-1614209216895.png

 

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.

 

0 Kudos
Message 28 of 28
(959 Views)