ListSetIndex

InstallShield 2014 » InstallScript Language Reference

The ListSetIndex function makes a specific element in a string or number list the current element, using an index. You can also use constants to traverse a list one element at a time or to jump to the beginning or end of a list. By using indices to access items in a list, you can treat numeric and string lists as arrays.

After you set the indexed element as the current element, you can use either the ListCurrentItem or ListCurrentString function in the script to retrieve the value of the indexed (current) item.

Note: The ListSetIndex function works with both string and number lists.

Syntax

ListSetIndex (listID, nIndex);

Parameters

ListSetIndex Parameters

Parameter

Description

listID

Specifies the name of the string or number list whose index is to be set.

nIndex

Specifies the number of the element you want to set as the current element. List element numbering begins at zero (0). For example, if you enter 5 in the parameter nIndex, the item in the sixth physical location in the list becomes the current element.

Pass a numeric value or one of the following predefined constants in this parameter:

LISTFIRST—Moves to the first element in the list.
LISTLAST—Moves to the last element in the list.
LISTNEXT—Moves to the next element in the list.
LISTPREV—Moves to the previous element in the list.

Return Values

ListSetIndex Return Values

Return Value

Description

0

Indicates that the function successfully updated the current element in the list.

< 0

Indicates that the function was unable to update the current element the list.

END_OF_LIST (1)

Indicates that the index is out of range of available list elements.

ISERR_LIST_NOSUCHLIST (-501)

Indicates that a list with the specified ID does not exist. Valid list IDs are return values from the ListCreate function.

See Also