These functions were primarily designed to be anologous to using FormList functions, just with arrays. You won't be able to use these with integers or floats without some re-work.
Also please suggest if it looks like something could be done better, or if I made a mistake. The names are similar to the FormList functions, to avoid confusion as to their purpose.
All of the examples use a generic input parameter of type Form, but you will need to change the type of the array input parameter / form to the type of array / forms you're using, or perhaps call it "as Form" (though I haven't tested it this way).
Enjoy

bool function ArrayAddForm(Form[] myArray, Form myForm)
Adds a form to the first available element in the array.
Spoiler
bool function ArrayAddForm(Form[] myArray, Form myForm) ;-----------\ ;Description \ Author: Chesko ;---------------------------------------------------------------- ;Adds a form to the first available element in the array. ;-------------\ ;Return Values \ ;---------------------------------------------------------------- ; false = Error (array full) ; true = Success int i = 0 ;notification("myArray.Length = " + myArray.Length) while i < myArray.Length if myArray[i] == none myArray[i] = myForm ;notification("Adding " + myForm + " to the array.") return true else i += 1 endif endWhile return falseendFunctionbool function ArrayRemoveForm(Form[] myArray, Form myForm, bool bSort = false)
Removes a form from the array, if found. Sorts the array using ArraySort() if bSort is true.
Spoiler
Example:bool function ArrayRemoveForm(Form[] myArray, Form myForm, bool bSort = false) ;-----------\ ;Description \ Author: Chesko ;---------------------------------------------------------------- ;Removes a form from the array, if found. Sorts the array using ArraySort() if bSort is true. ;-------------\ ;Return Values \ ;---------------------------------------------------------------- ; false = Error (Form not found) ; true = Success int i = 0 while i < myArray.Length if myArray[i] == myForm myArray[i] = none ;notification("Removing element " + i) if bSort == true ArraySort(myArray) endif return true else i += 1 endif endWhile return false endFunctionArrayRemoveForm(myWeaponArray, myWeapon as Form) ;Removes myWeapon from myWeaponArray, if found.ArrayRemoveForm(myArmorArray, myArmor as Form, true) ;Removes myArmor from myArmorArray if found, and re-sorts the the array (makes all data contiguous)
bool function ArraySort(Form[] myArray, int i = 0)
Removes blank elements by shifting all elements down.
Spoiler
bool function ArraySort(Form[] myArray, Int i = 0) ;-----------\ ;Description \ Author: Chesko ;---------------------------------------------------------------- ;Removes blank elements by shifting all elements down. ;Optionally starts sorting from element i. ;-------------\ ;Return Values \ ;---------------------------------------------------------------- ; false = No sorting required ; true = Success bool bFirstNoneFound = false int iFirstNonePos = i while i < myArray.Length if myArray[i] == none if bFirstNoneFound == false bFirstNoneFound = true iFirstNonePos = i i += 1 else i += 1 endif else if bFirstNoneFound == true ;check to see if it's a couple of blank entries in a row if !(myArray[i] == none) ;notification("Moving element " + i + " to index " + iFirstNonePos) myArray[iFirstNonePos] = myArray[i] myArray[i] = none ;Call this function recursively until it returns ArraySort(myArray, iFirstNonePos + 1) return true else i += 1 endif else i += 1 endif endif endWhile return falseendFunctionfunction ArrayClear(Form[] myArray)
Deletes the contents of this array.
Spoiler
function ArrayClear(Form[] myArray) ;-----------\ ;Description \ Author: Chesko ;---------------------------------------------------------------- ;Deletes the contents of this array. ;-------------\ ;Return Values \ ;---------------------------------------------------------------- ; none int i = 0 while i < myArray.Length myArray[i] = none i += 1 endWhileendFunction
int function ArrayCount(Form[] myArray)
Counts the number of indices in this array that do not have a "none" type.
Spoiler
int function ArrayCount(Form[] myArray) ;-----------\ ;Description \ Author: Chesko ;---------------------------------------------------------------- ;Counts the number of indices in this array that do not have a "none" type. ;-------------\ ;Return Values \ ;---------------------------------------------------------------- ; int myCount = number of indicies that are not "none" int i = 0 int myCount = 0 while i < myArray.Length if myArray[i] != none myCount += 1 i += 1 else i += 1 endif endWhile ;notification("MyCount = " + myCount) return myCountendFunctionint function ArrayHasForm(Form[] myArray, Form myForm)
Attempts to find the given form in the given array, and returns the index of the form if found.
Spoiler
int function ArrayHasForm(Form[] myArray, Form myForm) ;-----------\ ;Description \ Author: Chesko ;---------------------------------------------------------------- ;Attempts to find the given form in the given array, and returns the index of the form if found. ;-------------\ ;Return Values \ ;---------------------------------------------------------------- ; -1 = Form not found ; int i = Location of the form int i = 0 while i < myArray.Length if myArray[i] == myForm return i else i += 1 endif endWhile return -1endFunction

