Function Reference


Add new values without increasing array size by inserting at the end the new value and deleting the first one or vice versa

#include <Array.au3>
_ArrayPush ( ByRef $aArray, $vValue [, $iDirection = 0] )


$aArray Array to modify
$vValue Value(s) to add (can be in an array)
$iDirection [optional] Direction to push existing array elements:
    0 = Slide left (adding at the end)
    1 = Slide right (adding at the start)

Return Value

Success: 1.
Failure: 0 and sets the @error flag to non-zero.
@error: 1 - $aArray is not an array
2 - $vValue is an array larger than $aArray (so it can't fit)
3 - $aArray is not a 1D array


This function is used for continuous updates of data in array, where in other cases a vast size of array would be created.
It keeps all values inside the array (something like History), minus the first one or the last one depending on direction chosen.
It is similar to the push command in assembly.


_ArrayAdd, _ArrayConcatenate, _ArrayDelete, _ArrayInsert, _ArrayPop


#include <Array.au3>

Local $avArrayTarget[9] = [1, 2, 3, 4, 5, 6, 7, 8, 9]
Local $avArraySource[2] = [100, 200]

_ArrayDisplay($avArrayTarget, "$avArrayTarget BEFORE _ArrayPush()")
_ArrayPush($avArrayTarget, $avArraySource)
_ArrayDisplay($avArrayTarget, "$avArrayTarget AFTER _ArrayPush() array to end")
_ArrayPush($avArrayTarget, $avArraySource, 1)
_ArrayDisplay($avArrayTarget, "$avArrayTarget AFTER _ArrayPush() array to beginning")
_ArrayPush($avArrayTarget, "Hello world!", 1)
_ArrayDisplay($avArrayTarget, "$avArrayTarget AFTER _ArrayPush() string to beginning")