See Also: Array Functions, Array Variable Assignments, Working with Arrays
Fills an array element range with a specified value.
(FillArray( {assignVal}, {ArrayId} [, {indexFirst}, {indexLast} ] ))
Where:
{assignVal} is the value that will be assigned to each array element in the specified range.
{ArrayId} is the id of the array to retrieve a range of elements from.
{indexFirst} is the index of the first element in the range to assign a value to.
{indexLast} is the index of the last element in the range to assign a value to.
Iterates the array elements from {indexFirst} to {indexLast} and assigns each element in that range the value {assignVal}. This is useful for initializing arrays with default values. FillArray does not create new elements in an array, it only fills existing elements with values.
This sample fills all elements of a string array with the value "None".
String[] sCustomers
// ToDo: add some elements to the array -- only existing elements will be filled
Move (FillArray("None", sCustomers)) to sCustomers
This sample fills the first 20 elements of a string array with the value "None".
String[] sCustomers
// ToDo: add at least 20 elements to the array -- only existing elements will be filled
Move (FillArray("None", sCustomers, 0, 19)) to sCustomers
This sample places default values into a struct of type tUSAddress (DefaultAddress), then fills all elements of an array of tUSAddress structs with the defaulted values in the DefaultAddress struct.
Struct tUSAddress
String Street
String City
String State
Integer ZipCode
End_Struct
// fires when the button is clicked
Procedure OnClick
tUSAddress[] sCustomerAddresses
tUSAddress DefaultAddress
// fill DefaultAddress struct with default values
Move "" to DefaultAddress.Street
Move "Miami" to DefaultAddress.City
Move "FL" to DefaultAddress.State
Move 33186 to DefaultAddress.ZipCode
// ToDo: add some elements to sCustomerAddresses array -- only existing elements will be filled
// copy values from DefaultAddress struct to each of the structs
// in the sCustomerAddresses array
Move (FillArray(DefaultAddress, sCustomerAddresses)) to sCustomerAddresses
End_Procedure // OnClick
This sample fills a multidimensional array. This cannot be done directly, but instead this sample shows you how to loop through the outer dimension of the array and fill it one row at a time. Afterwards, the sample displays the array values to the screen.
// fires when the button is clicked
Procedure OnClick
String[][] sCustomers
Integer i j iDim1Size iDim2Size
// ToDo: add some elements to sCustomers array -- only existing elements will be filled
// loop through outer dimension
For i From 0 to 9
// fill array one row at a time
Move (FillArray("None", sCustomers[i])) to sCustomers[i]
Loop
// display values in array
Move (SizeOfArray(sCustomers)) to iDim1Size
Move (SizeOfArray(sCustomers[1])) to iDim2Size
For i From 0 to (iDim1Size-1)
For j From 0 to (iDim2Size-1)
show sCustomers[i][j]
show " "
Loop
showln
Loop
End_Procedure // OnClick