AppendArray

See Also: SizeOfArray, ResizeArray, Array Functions, Array Variable Assignments, Working with Arrays

Purpose

Returns an array consisting of one array appended to another array.

Return Type

Array

Syntax

AppendArray( {Array1Id}, {Array2Id} )

AppendArray( {Array1Id}, {Array2Id} [, {indexFirst}, {indexLast} ])

Where:

What it Does

Returns an array consisting of one array appended to another array. If {indexFirst} and {indexLast} are passed, only that sub-range of the second array is appended to the first array. The arrays must be of the same type. Both source arrays and the destination array must be dynamic.

This can be particularly useful when working with UChar arrays.

Use InsertInArray to insert or append individual array elements to an array.

Use RemoveFromArray to remove elements from an array.

Example

The below example appends the names in source arrays sGroupAmericaNames and sGroupEuropeNames and places them in destination array sCombinedGroupNames.

The result would be: John, Marcia, Americo, Dennis, Chip, Vincent, Nick, Janine, Harm, Eddie

Procedure OnClick

    String[] sGroupAmericaNames sGroupEuropeNames sCombinedGroupNames

    

    Move "John" to sGroupAmericaNames[0]

    Move "Marcia" to sGroupAmericaNames[1]

    Move "Americo" to sGroupAmericaNames[2]

    Move "Dennis" to sGroupAmericaNames[3]

    Move "Chip" to sGroupAmericaNames[4]

    

    Move "Vincent" to sGroupEuropeNames[0]

    Move "Nick" to sGroupEuropeNames[1]

    Move "Janine" to sGroupEuropeNames[2]

    Move "Harm" to sGroupEuropeNames[3]

    Move "Eddie" to sGroupEuropeNames[4]

    

    Move (AppendArray(sGroupAmericaNames, sGroupEuropeNames)) to sCombinedGroupNames

End_Procedure

The names in the destination array are added in the order they are received from the source arrays. You could call SortArray to sort the destination array:

Move (SortArray(sCombinedGroupNames)) to sCombinedGroupNames

The result would be: Americo, Chip, Dennis, Eddie, Harm, Janine, John, Marcia, Nick, Vincent.

Example

The below example appends the names in source array sGroupEuropeNames from array indexer 3 to 4 and to all names in source arrays sGroupAmericaNames and places them in destination array sCombinedGroupNames.

The result would be: John, Marcia, Americo, Dennis, Chip, Harm, Eddie

Procedure OnClick

    String[] sGroupAmericaNames sGroupEuropeNames sCombinedGroupNames

    

    Move "John" to sGroupAmericaNames[0]

    Move "Marcia" to sGroupAmericaNames[1]

    Move "Americo" to sGroupAmericaNames[2]

    Move "Dennis" to sGroupAmericaNames[3]

    Move "Chip" to sGroupAmericaNames[4]

    

    Move "Vincent" to sGroupEuropeNames[0]

    Move "Nick" to sGroupEuropeNames[1]

    Move "Janine" to sGroupEuropeNames[2]

    Move "Harm" to sGroupEuropeNames[3]

    Move "Eddie" to sGroupEuropeNames[4]

    

    Move (AppendArray(sGroupAmericaNames, sGroupEuropeNames, 3, 4)) to sCombinedGroupNames

End_Procedure