Click or drag to resize

AFill Function

Fill array elements with a specified value.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.07
Syntax
 FUNCTION AFill(
	aTarget AS ARRAY,
	uValue AS USUAL := NIL,
	nStart AS USUAL := NIL,
	nCount AS USUAL := NIL
) AS ARRAY
View Source

Parameters

aTarget
Type: Array
The array to fill.
uValue (Optional)
Type: Usual
The value to place in each array element.
nStart (Optional)
Type: Usual
The starting element.  A negative value starts from the end.  If <nCount> is  positive, the default value is 1; if <nCount> is negative, the default value is the length of the array.
nCount (Optional)
Type: Usual
The number of elements to process from <nStart>.  A negative value starts from the end.  The default is all elements to the end of the array.

Return Value

Type: Array
A reference to <aTarget>.
Remarks
AFill() fills the specified array with a single value of any data type by assigning <uValue> to each array element in the specified range. Using AFill with a multidimensional array could overwrite subarrays used for the other dimensions of the array.
Examples
This example creates a 3-element array.  The array is then filled with the logical value FALSE.  Finally, elements in positions 2 and 3 are assigned the new value TRUE:
X#
LOCAL aLogic[3]                        // aLogic is {NIL, NIL, NIL}
AFill(aLogic, FALSE)                // aLogic is {FALSE, FALSE, FALSE}
AFill(aLogic, TRUE, 2, 2)                // aLogic is {FALSE, TRUE, TRUE}
This example fills up the individual rows of a multidimensional array:
X#
LOCAL a2[3][3]        //a 2-dimensional array
AFill(a2[1], "One")
AFill(a2[2], "Two")
AFill(a2[3], "Three")
See Also