11.22 insert()

With this function a new value can be inserted into a collection (data types hash, list, matrix, refvec and vector) or a string once or several times.

The new values are inserted before the specified position. The position must be >= 1, i.e. it is not possible to insert default values at the indices [0] or [0,0] with this function. The largest possible position is 1 higher than the current countof(ListValue) to enable appending to an existing collection.

In general, the data type of the (optional) new value has to be a scalar and match the value type of the collection.

The number of repetitions for the inserting (Count parameter) has to be >= 0.

In case of an error, the function call is aborted with a fail.

Definition

anyalue insert
(
      anyvalue ListValue  input,
      integer  Pos   input
  { , integer  Count := 1 input }
  { , enum     Dir   := dir_row input }
  { , anyvalue NewValue   input }
)

Parameters

anyvalue ListValue input
This parameter specifies the collection or string where a value shall be inserted.
integer Pos input
In this parameter, the index position is defined before which the insertion occurs. Values >= 1 are permitted. For matrix collections, depending on the Dir parameter, Pos represents either a row position (dir_row) or a column position (dir_column).
integer Count := 1 input
This optional parameter defines the number of times a new value (respectively how many rows or columns) shall be inserted. Values >= 0 are allowed, with no insertion being performed for 0.
enum Dir := dir_row input
This optional parameter defines the orientation of the index position, which is important for a matrix. The default value dir_row means that rows are inserted in the matrix. With dir_column columns are inserted.
anyvalue NewValue input
This optional parameter defines the new value to be inserted. The value must match the value type of the collection.

Return value

The function returns the modified collection respectively the modified string.

Particularities

Examples

Availability

Since IDM version A.06.02.g

See also

Built-in functions append(), delete()