37.4.2 Assigning a value to a list-variable item

To specify the value of an item in a list, use an assignment that includes the index position of the item in brackets (see §37.3.2 Assigning values to macro variables):

<$$listname[index] = somevalue>

How the value is assigned depends on whether you include or omit a default value:

Set a default value

Omit a default value .

Set a default value

If you provide a value for list item 0 (zero), that value is used for any item in the list for which you have not specified another value. For example, suppose you specify:

<$$mylist[0] = Error!>

Then if you use <$$mylist[15]>, without ever having assigned a value to the 15th item in the list, that value becomes “Error!”.

Omit a default value

If you do not provide a value for <$$mylist[0]>, and you use <$$mylist[15]>, the value of <$$mylist[15]> is 0 (zero).

Previous Topic:  37.4.1 Understanding list-variable syntax

Next Topic:  37.4.3 Initializing list variables

Parent Topic:  37.4 Using multiple-value list variables

Sibling Topics:

37.4.1 Understanding list-variable syntax

37.4.3 Initializing list variables

37.4.4 Using macros to process lists

37.4.5 Using pointers to process lists

37.4.6 Using a list instead of a conditional expression

Table of ContentsIndex