Admin Production ni-theme
Current Publication

GetCtrlArrayItem

LabWindows/CVI

GetCtrlArrayItem

int GetCtrlArrayItem (int controlArrayHandle, int index);

Purpose

Returns the control ID at the specified index of the control array.

You can use this function and GetNumCtrlArrayItems to iterate through the controls in an array. Assuming that ctrlArray is an array of LED controls, the following example code iterates through the control array and turns on LED controls with odd array indices and turns off LED controls with even array indices.

GetNumCtrlArrayItems(ctrlArray, &count);
   for (i=0; i<count; i++)
      SetCtrlVal(panelHandle, GetCtrlArrayItem(ctrlArray, i), i%2);

Parameters

Input
Name Type Description
controlArrayHandle int Specifier for a particular control array that is currently in memory. You obtain this handle from GetCtrlArrayFromResourceID or NewCtrlArray.
index int Zero-based index of the control.

Return Value

Name Type Description
controlID int The control ID you can use in subsequent function calls to specify this control. A negative value indicates that an error occurred.

Additional Information

Library: User Interface Library

Include file: userint.h

LabWindows/CVI compatibility: LabWindows/CVI 2010 and later

Example

Refer to userint\ledctrlarray.cws for an example of using the GetCtrlArrayItem function.