wcSetItemData() Function
- Last UpdatedFeb 21, 2017
- 1 minute read
Assigns an integer value of the item (the Number parameter) to the item in the list specified by the ItemIndex parameter. This function enables the assignment of a number to a string.
Category
windows control
Syntax
[ErrorNumber=]wcSetItemData("ControlName", ItemIndex, Number);
Parameters
ControlName
The name of the windows control object. For example, ListBox_1. Actual string or message tagname.
ItemIndex
An integer value specifying the list item you want to edit. Any number or Integer tagname.
Number
An integer value representing the item data. Any number or Integer tagname.
Remarks
You can create complete lists containing the items using a program like Notepad and then load them using one function call. Format the list as required by the wcSaveList() function.
For a list of returned error numbers, see Understand windows controls error messages.
Use the wcGetItemData() function to return the value (item data) associated with the list item. The tagname parameter contains the returned numeric value. This parameter could be an I/O Integer tagname that writes directly to the real world device.
Example(s)
A recipe has three ingredients; flour, sugar and salt. The quantity of flour is 4500 grams, sugar is 1500 and salt is 325 grams. The values are assigned to each of the list box items by using a data change script triggered by what recipe (tagname, RecipeName) is selected:
wcSetItemData("ListBox_1", 1, 4500); {set 1st item in the list (flour)=4500}
wcSetItemData("ListBox_1", 2, 1500); {set 2nd item in the list (sugar)=1500}
wcSetItemData("ListBox_1", 3, 325); {set 3rd item in the list (salt)=325}
See Also
wcLoadList(), wcSaveList(), wcGetItemData()