Bunoon: TESS | Manual | Array

This area contains a set of functions that are used for handling and manipulating Arrays, either single or multi-dimensional. Arrays are useful for storing information in a specific order (that is not sorted). Also in this area, you will find functions that will allow you to search arrays for specific items, marge several together, remove items (by either value or index) and much more.

If you are looking to store your information into property types, please see the Objects documentation page.

Takes an array and merges it with a list (from arguments) of arrays.

The main arguments for this function are as follows:

  • aArray [Array] - The array that should be merged into.
  • [arguments] - An arguments object array containing the list of arrays to merge with.

The return value for this function is as follows:

  • [Object] - An array with all the additional arrays merged (or null if any error has occurred).

Below is an example of how to use this function:

var aArray1 = [1, 2, 3, 4];

var aArray2 = [5, 6, 7, 8];

var aArray3 = [9, 10, 11, 12];


var aMerged = $T.Array.Merge(aArray1, aArray2, aArray3);

Takes an array and clones it as a return value.

The main arguments for this function are as follows:

  • aArray [Array] - The array that should be cloned.

The return value for this function is as follows:

  • [Object] - A cloned array (or the object passed itself if not valid).

Below is an example of how to use this function:

var aArray = [1, 2, 3, 4];


var aClone = $T.Array.Clone(aArray);

Takes an array and ensures that it is completely cleared.

The main arguments for this function are as follows:

  • aArray [Array] - The array that should be cleared.

The return value for this function is as follows:

  • [Object] - An empty array (or null if any error has occurred).

Below is an example of how to use this function:

var aArray = [1, 2, 3, 4];


aArray = $T.Array.Clear(aArray);

Takes an array and adds the specified item to the start/end (end by default).

The main arguments for this function are as follows:

  • aArray [Array] - The array that should be cleared.
  • oItem [Object] - The item that should be added to the array.
  • bStart [Boolean] - States if the item should be added to the start or end of the array (false by default for end).

The return value for this function is as follows:

  • [Object] - An array containing the new item (or null if any error has occurred).

Below is an example of how to use this function:

var aArray = [1, 2, 3, 4];


aArray = $T.Array.Add(aArray, 5, false);

Takes an array and removes all the duplicates it finds (returns an object containing a new list of duplicates found).

The main arguments for this function are as follows:

  • aArray [Array] - The array that should be checked and updated.

The return value for this function is as follows:

  • [Object] - An Object() (containing .Array and .Duplicates arrays) with the new details.

Below is an example of how to use this function:

var aArray = [1, 2, 3, 4, 4, 2];


var oDetails = $T.Array.RemoveDuplicates(aArray, 5, false);


aArray = oDetails.Array;

Takes an array and searches through it to find a specific object (by type).

The main arguments for this function are as follows:

  • aArray [Array] - The array that should be searched.
  • oSearchItem [Object] - The object we are looking for (string, number, object, etc).

The return value for this function is as follows:

  • [Object] - A number stating the position in the array the item exists (or null if any error has occurred).

Below is an example of how to use this function:

var aArray = [1, 2, 3, 4];


var nPosition = $T.Array.Find(aArray, 2);

Takes an array and deletes a specific item from it.

The main arguments for this function are as follows:

  • aArray [Array] - The array that should be updated.
  • oItem [Object] - The object we are to delete from the array.

The return value for this function is as follows:

  • [Object] - The array with the item removed (or null if any error has occurred).

Below is an example of how to use this function:

var aArray = [1, 2, 3, 4];


aArray = $T.Array.DeleteValue(aArray, 2);

Takes an array and deletes a specific item from it by it's index position.

The main arguments for this function are as follows:

  • aArray [Array] - The array that should be updated.
  • nIndex [Number] - The index position of the item that should be removed from the array.
  • nCount [Number] - The number of items after the index that should be removed as well (defaults to 1 to represent just the item itself).

The return value for this function is as follows:

  • [Object] - The array with the indexed item removed (or null if any error has occurred).

Below is an example of how to use this function:

var aArray = [1, 2, 3, 4];


aArray = $T.Array.DeleteIndex(aArray, 3, 1);

Takes an arguments object and converts it into an array, while stripping away a specific number of items from the start.

The main arguments for this function are as follows:

  • oArguments [Array] - The arguments object to be converted.
  • nShifts [Number] - The number of arguments to strip away at the beginning of the new array.

The return value for this function is as follows:

  • [Object] - The arguments converted into an array (or null if any error has occurred).

Below is an example of how to use this function:

function ShowElements (bShow) {

var oArguments = $T.Array.FromArguments( arguments, 1 );

}


ShowElements(true, element1, element2);