Insert - method of the PmArray object

Adds one or multiple items into the array. The array is enlarged by the added items.
It is functional only for 1-dimensional array.
Empty Insert(Long nPos, Variant vValues, [Long nAttr])
nPos(Long) The index of the item to be added. The current item on this index and following items will be shifted behind the added items.
The -2 value means adding to the end.
vValues(Variant) Added value or array of added values.
nAttr[optional] (Long) The parameter specifies the behavior if the value of the vValues parameter contains 1-dimensional array.
0 (default) - The content of the vValues parameter is always added as a single item.
1 - If the vValues parameter contains 1-dimensional array then individual items of such array are added into the array (multiple items are added at once). Otherwise the value of the vValues parameter is added as a sigle item.
The Insert method allows adding items to the beginning, to the end and aslo to the inside of an existing array and the Remove method allows removing items from beginning, from the end and aslo from the inside of an existing array.
However, this method is very slow and not suitable for fast automatic processing of data arrays. It is better to allocate a larger array size in advance and after filling it with values, remove the empty items by the Remove method. See Example2.

This method is also functional in Web panels.
Adds a2 array into a1 array to position 2
JavaScriptSelect and copy to clipboard

var a1 = Pm.CreatePmArray().Array1(0, 10, 20, 30);
var a2 = Pm.CreatePmArray().Array1(12, 13, 14);
a1.Insert(2, a2, 0);   // Result: (0, 10, (12, 13, 14), 20, 30)
// or
a1.Insert(2, a2, 1);   // Result: (0, 10, 12, 13, 14, 20, 30)

Pm9.00.04: Created
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.