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.6
Syntax
 FUNCTION AFill(
	aTarget AS ARRAY,
	 uValue AS USUAL,
	 nStart AS USUAL,
	 nCount AS USUAL
) AS ARRAY
Request Example View Source

Parameters

aTarget
Type: Array
The array to fill.
uValue
Type: Usual
The value to place in each array element.
nStart
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
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#
1LOCAL aLogic[3]            // aLogic is {NIL, NIL, NIL}
2AFill(aLogic, FALSE)        // aLogic is {FALSE, FALSE, FALSE}
3AFill(aLogic, TRUE, 2, 2)        // aLogic is {FALSE, TRUE, TRUE}
This example fills up the individual rows of a multidimensional array:
X#
1LOCAL a2[3][3]    //a 2-dimensional array
2AFill(a2[1], "One")
3AFill(a2[2], "Two")
4AFill(a2[3], "Three")
See Also