mklst(N;X)
Returns a single, indexed list-value containing multiple instances of the given value.
Syntax
mklst(N;X)
Input
| Argument | Type | Description |
|---|---|---|
N |
integer | Number of times to repeat value XIf If A scalar value |
X |
any | Value to repeat N timesA scalar value |
Return Value
Returns a single list-value that contains a list of N instances of value
X.
If X is N/A, the values contained in the list-value are N/A.
Sample Usage
list="mklst(2;'Enter a value')"returns a list-value called
list, which itself contains 2 text values, each with the value of:
Enter a value. The values are indexed in order starting at
1.Example: Storing multiple input values
mklst(N;X) is useful for creating a list used to store a known number of
values. In this example, mklst(N;X) creates a list of two elements. Each
element is initialized to a default value that will be displayed when each field widget is
rendered. Each element will be used to store the value submitted by its corresponding field
widget. <dynamic> tag and will work on
any table.<dynamic fieldvalues="{mklst(2;'Enter a value')}"> <for i="1" to="2"> <widget class_="field" label_="Field #{@i}" value_="@fieldvalues.{@i}"/> </for> </dynamic>
<for> loop. If
N is 2 and to="3" (producing 3
iterations of the <for> loop), the third field widget created will not
properly render. The code above creates a 2-element list-value containing 2 instances of the text value:
Enter a value. When a new value is entered in a field and submitted, it
will be stored at the list element corresponding to the index value used when the list was
created and its values initialized. So, if a user enters the value Bluth's
Bananas in Field #1, then that text value is stored in
fieldvalues.1.

