Use the tabs on the upper right to switch to a different programming language.

Use the tabs on the upper right to switch to a different programming language.

Use the tabs on the upper right to switch to a different programming language.

Use the tabs on the upper right to switch to a different programming language.

insertinsertInsertInsertinsert (Operator)

Name

insertinsertInsertInsertinsert — Assignment of a value to a tuple element.

Warning

insertinsertInsertInsertInsertinsert is obsolete and is only provided for reasons of backward compatibility. The modifying version of the insertinsertInsertInsertInsertinsert operator was replaced by the operator assign_atassign_atAssignAtAssignAtAssignAtassign_at. This operator uses the same notation in the full text editor, so that it is used automatically. The non-modifying version of the insertinsertInsertInsertInsertinsert operator is replaced by the new operator tuple_replacetuple_replaceTupleReplaceTupleReplaceTupleReplacetuple_replace.

Signature

insert( : : Input, Value, Index : Result)

Herror insert(double Input, double Value, const Hlong Index, double* Result)

Herror T_insert(const Htuple Input, const Htuple Value, const Htuple Index, Htuple* Result)

void Insert(const HTuple& Input, const HTuple& Value, const HTuple& Index, HTuple* Result)

static void HOperatorSet.Insert(HTuple input, HTuple value, HTuple index, out HTuple result)

def insert(input: MaybeSequence[Union[int, float, str]], value: Union[int, float, str], index: int) -> Sequence[Union[int, float, str]]

def insert_s(input: MaybeSequence[Union[int, float, str]], value: Union[int, float, str], index: int) -> Union[int, float, str]

Description

insertinsertInsertInsertInsertinsert assigns a single value to a specific element of a tuple.

In the full text editor an insert operation is simply entered with the help of the assignment operator sign := and the index access operator sign [ ] for the result variable, e.g.: Areas[Radius-1] := Area

If the operator window is used for entering the insert operator, insert must be entered into the operator combo box as the operator name. This opens the parameter area, where the parameter ValueValueValueValuevaluevalue represents the expression that has to be evaluated to one value and assigned to the element at position IndexIndexIndexIndexindexindex within the tuple InputInputInputInputinputinput. The parameter ResultResultResultResultresultresult gets the name of the variable where the result has to be stored.

If the input tuple that is passed via the parameter InputInputInputInputinputinput and the output tuple that is passed in ResultResultResultResultresultresult are identical (and only in that case), the insertinsertInsertInsertInsertinsert operator is listed and can be written in the full text editor in the above assignment notation. In this case, the input tuple is modified and the correct operator notation for above assignment would be: insert (Areas, Area, Radius-1, Areas)

If the InputInputInputInputinputinput tuple and the ResultResultResultResultresultresult tuple differ, the input tuple will not be modified. In this case, within the program listing only the operator notation can be used: insert (Areas, Area, Radius-1, Result)

This is the same as: Result := Areas Result[Radius-1] := Area

Please note that the operator insertinsertInsertInsertInsertinsert will not increase the tuple if the tuple already stores a value at the passed index. Instead of that the element at the position IndexIndexIndexIndexindexindex will be replaced. Hence, for the ValueValueValueValuevaluevalue parameter exactly one single value (or an expression that evaluates to one single value) must be passed.

If the passed IndexIndexIndexIndexindexindex parameter is beyond the current tuple size, the tuple will be increased to the required size. The tuple elements that were inserted between the hitherto last element and the new element are undefined.

Parameters

InputInputInputInputinputinput (input_control)  real(-array) HTupleMaybeSequence[Union[int, float, str]]HTupleHtuple (real / integer / string) (double / int / long / string) (double / Hlong / HString) (double / Hlong / char*)

Tuple, where the new value has to be inserted.

Default value: []

ValueValueValueValuevaluevalue (input_control)  real HTupleUnion[int, float, str]HTupleHtuple (real / integer / string) (double / int / long / string) (double / Hlong / HString) (double / Hlong / char*)

Value that has to be inserted.

Default value: 1

Typical range of values: 0 ≤ Value Value Value Value value value ≤ 1000000

IndexIndexIndexIndexindexindex (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Index position for new value.

Default value: 0

Suggested values: 0, 1, 2, 3, 4, 5, 6

Minimum increment: 1

ResultResultResultResultresultresult (output_control)  real(-array) HTupleSequence[Union[int, float, str]]HTupleHtuple (real / integer / string) (double / int / long / string) (double / Hlong / HString) (double / Hlong / char*)

Result tuple with inserted values.

Result

If the expression is correct insertinsertInsertInsertInsertinsert returns TRUE. Otherwise, an exception is raised and an error code returned.

Alternatives

assignassignAssignAssignAssignassign

Module

Foundation