Language enhancement: .SPLICE statement now allows an optional fourth parameter to specify the splice position in the destination array:
.SPLICE $dst(), $src(), count, dstpos
where dstpos may be:
Value |
Meaning |
-1 (default) |
indicates end of the $dst() array |
0 |
indicates the start of the $dst() array |
n (n > 0) |
indicates after the nth item in $dst() array |
Note that this option only applies when the destination parameter is expressed as a base array, as in the above example. Attempting to specify the dstpos parameter when the first parameter is an iterator or other individual element reference will result in a syntax error.
Examples
If $kids() contains the list: "john", "fred", "sally", "pilar" and $pets() contains the list: "dog", "cat", "mouse", "lizard" then:
.SPLICE $kids(), $pets(), 1, 0
would splice "dog" to the start of the $kids() array.
.SPLICE $kids(), $pets(), 3, 2
would splice the first 3 pets ("dog", "cat", "mouse") after the 2nd kid, i.e. in between "fred" and "sally".
.SPLICE $kids(), $pets(), 0, -1
would be the same as
.SPLICE $kids(), $pets()
i.e. would splice all of the pets (count=0), to the end of the kids (-1).
.SPLICE $kids(), $pets(), 0, 0
would splice all of the pets to the start of the kids array.