dynInsertAt()

Inserts an element/elements in a field at the specified position.

Synopsis

int dynInsertAt(<dyn_type> &aDyn, [<type>|<dyn_type>] &aValue, int position);

Parameters

Parameter Meaning
aDyn Field into which the insertion is made
aValue Element(s) to be inserted
position Position at which the insertion is made

Return Value

The current number of field elements in aDyn, -1 in the event of an error.

Errors

A message is issued in the event of missing or incorrect arguments or incorrect variables.

Description

Inserts the element aValue in the field aDyn at the position "position". If aValue is a dynamic field, afterwards it will be empty, similarly to with dynAppend().

When a false index is given, the element is inserted at the end.

To insert values without changing the content of the inserted elements please refer to dynInsertAtConst()

Example

main()
{
  dyn_int d;
  d=makeDynInt(10,30,40);
  dynInsertAt(d,20,2); // 10 20 30 40
}

Assignment

Dynamic fields

Availability

CTRL