$Arr Init: Difference between revisions

From m204wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:$Arr_Init}}
{{DISPLAYTITLE:$Arr_Init}}
<span class="pageSubtitle">Initialize every element of an [[Using_variables_and_values_in_computation#Variable_arrays|array]] to specific value</span>
<span class="pageSubtitle">Initialize every element of an array to specific value</span>


<p class="warn"><b>Note: </b>Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no direct OO equivalent for the $Arr_Init function because the OO methods emphasize the use of [[Collections]] over the use of arrays.</p>
<p class="warn"><b>Note: </b>Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no direct OO equivalent for the $Arr_Init function because the OO methods emphasize the use of [[Collections]] over the use of arrays.</p>


<var>$Arr_Init</var> can be used to initialize every element of an array to a specific value.  
<var>$Arr_Init</var> can be used to initialize every element of an [[Using_variables_and_values_in_computation#Variable_arrays|array]] to a specific value.  


==Syntax==
==Syntax==

Revision as of 15:37, 8 January 2018

Initialize every element of an array to specific value

Note: Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no direct OO equivalent for the $Arr_Init function 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 receives a 0 or, if the array is invalid, a -1.

The first argument is 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.

The second argument is 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 and 0 if the first argument is either a fixed or float array.

Examples

  1. In the following example, every element of %FXARRAY is set to 0:

    %FXARRAY IS FIXED ARRAY(5) %RC = $Arr_Init(%FXARRAY)

  2. In the following example, every element of %STARRAY is set to '*** UNKNOWN ***':

    %STARRAY IS STRING LEN 20 ARRAY(5) %RC = $Arr_Init(%STARRAY, '*** UNKNOWN ***')

Products authorizing $Arr_Init