JavaScript global method: insertDatum

Inserts data into an array datum directly.

Syntax

insertDatum( array[, position[, number[, value[, denull]]]])

Arguments

The following parameters are valid for this function.

Parameter

Data type

Description

array

Array datum

The array parameter is the array into which an element is inserted.

position

Number

 

The position parameter is the position of the first inserted element. If the value is zero (0), the element is inserted at the end of the array. This is an optional parameter. The default value is zero (0).

number

Number

The number parameter is the number of elements to insert. This is an optional parameter. The default value is one (1). If the value is zero (0), this function will return without changing the array.

value

Any data type supported by RAD

The value parameter is a value to insert into the new elements. This is an optional parameter.

The default value is NULL.

denull

Boolean

The denull parameter is a logical value that determines whether or not the array should be denulled before inserting elements. This is an optional parameter. The default value is true.

Return values

The array is returned with the new data inserted.

Throws

None

Description

This method insert data directly into an existing array datum.

Examples

Action desired

Example and result

Insert an element at the beginning of an array datum

vars.$a=["a", "b", "c", "d"]; insertDatum(vars.$a, 1, 1, "z");

Returns: vars.$a = {"z", "a", "b", "c", "d"}

Insert an element in the middle of an array datum

vars.$a=["a", "b", "c", "d"]; insertDatum(vars.$a, 3, 1, "z")

Returns: vars.$a = {"a", "b", "z", "c", "d"}

Insert an element at the end of an array datum

vars.$a=["a", "b", "c", "d"]; insertDatum(vars.$a, 0, 1, "z");

Returns: vars.$a = {"a", "b", "c", "d", "z"}

To denull the array datum

vars.$a=["a", "b", null, null, "e", "f", null, null, null, null]; insertDatum(vars.$a, 0, 1, "z");

Returns: vars.$a = {"a", "b", , , "e", "f", "z"}

To avoid denulling the array datum

vars.$a=["a", "b", null, null, "e", "f", null, null, null, null]; insertDatum(vars.$a, 0, 1, "z", 0);

Returns: vars.$a = {"a", "b", , , "e", "f", , , , ,"z"}

To denull the array datum again

vars.$a=["a", "b", null, null, "e", "f", null, null, null, null]; insertDatum(vars.$a, 2, 1, "z");

Returns: vars.$a = {"a", "z", "b", , , "e", "f"}