$Arr_Init
Initialize every element of an array to specific value
Note: Many $functions have been deprecated in favor of Object Oriented methods. There is no direct OO equivalent for $Arr_Init, because the OO methods emphasize the use of Collections over the use of arrays.
$Arr_Init can be used to initialize every element of an array to a specific value.
Syntax
%result = $Arr_Init (array, value)
%result | A numeric value that receives a 0 or, if the array is invalid, a -1. |
---|---|
array | An array of string, float, or fixed values. This array can be a single or multi-dimensional array and must not be an array in an image. |
value | The value with which the array is to be initialized. If this argument is not specified, it defaults to a null string if the first argument is a string array, or it defaults to 0 if the first argument is a fixed or float array.
For string array elements, the value assigned is truncated if the value is longer than the element length. |
Examples
- In the following example, every element of
%fxarray
is set to 0:%fxarray is fixed array(5) %rc = $Arr_Init(%fxarray)
- In the following example, every element of
%starray
is set to*** UNKNOWN ***
:%starray is string len 20 array(5) %rc = $Arr_Init(%starray, '*** UNKNOWN ***')