Siebel eScript Language Reference > Methods Reference > Array Methods >

Insert Array Elements Method


The Insert Array Elements method inserts array elements into an array. It returns an array that includes the elements that it removed from the original array. It does the following work:

  1. Beginning at the value that the start argument specifies, it deletes the number of array elements that the deleteCount argument specifies.
  2. Inserts these deleted elements into the newly created return array in the same order that it uses to delete them.
  3. To make room for new elements, it adjusts the elements in the current array object.
  4. Inserts the array elements that you specify in the element1, element2, . . . elementn argument. It inserts these elements sequentially in the space that it creates in Step 3.
Format

arrayName.splice(start, deleteCount[, element1, element2, . . . elementn])

Table 33 describes the arguments for the Insert Array Elements method.

Table 33. Arguments for the Insert Array Elements Method
Argument
Description

start

Identifies the index where this method inserts the new array elements. This method does the following:

  • If start is negative, then it uses the value of the length of the array plus start. It inserts at the position counting back from the end of the array. For example, the following code inserts from the last element in the array:

    start = -1

  • If start is larger than the index of the last element, then it uses the length of the array. It appends new elements to the end of the array.

deleteCount

Identifies the number of array elements to remove from the array. If deleteCount is larger than the number of elements that exist in the array, then this method removes all of the elements.

element1, element2, . . . elementn

A list of elements that this method inserts in the array.

Example

The following example includes the Insert Array Elements method:

var a = new Array( 1, 2, 3, 4, 5 );
TheApplication().RaiseErrorText(a.splice(1,3,6,7) + " " + a);
// Displays 2,3,4   1,6,7,5
// Beginning at element in position 1, three elements (a[1], a[2], a[3] = 2,3,4)
// are replaced with 6,7.

Siebel eScript Language Reference Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.