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 X

If N is omitted, an error is returned.

If N is N/A, an error is returned.

A scalar value

X any Value to repeat N times

A 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

As an example, the following function call:
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.
Note: The example below uses the <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>
Note: In the example above, the number of elements in the list-value that is created must correspond to the number of iterations of the <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.