$Arr Init: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (add italics)
 
(38 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:$Arr_Init}}
{{DISPLAYTITLE:$Arr_Init}}
<span class="pageSubtitle">Initialize every element of array to specific value</span>
<span class="pageSubtitle">Initialize every element of an array to specific value</span>


<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no direct OO equivalent for the <var>$Arr_Init</var> function because the OO methods emphasize the use of [[Collections]] over the use of arrays.</p>
<p class="warn"><b>Note:</b> Many $functions have been deprecated in favor of Object Oriented methods. There is no direct OO equivalent for <var>$Arr_Init</var>, 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> accepts two arguments and returns a numeric code.  
<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.  


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.
==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" /> %RESULT = $Arr_Init (array, value)
<p class="syntax"><span class="term">%result</span> = $Arr_Init (<span class="term">array, value</span>)
<section end="syntax" /></p>
<p class="caption">$Arr_Init Function
</p>
</p>
<p class="caption">%RESULT returns a 0 or, if the array is invalid, a -1.</p>


<table>
<tr><th>%result</th>
<td>A numeric value that receives a 0 or, if the array is invalid, a -1.
</td></tr>
<tr><th>array</th>
<td>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.
<tr><th>value</th>
<td>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.
<p>
For string array elements, the value assigned is truncated if the value is longer than the element length. </p></td></tr>
</table>


In the following example
==Examples==
<p class="code"> %FXARRAY IS FIXED ARRAY(5)
<ol>
<li>In the following example, every element of <code>%fxarray</code> is set to 0:
<p class="code">%fxarray is fixed array(5)
   
   
%RC = $Arr_Init(%FXARRAY)
%rc = $Arr_Init(%fxarray)
</p>
</p>
every element of %FXARRAY is set to 0.


In the following example
<li>In the following example, every element of <code>%starray</code> is set to <code>*** UNKNOWN ***</code>:
<p class="code"> %STARRAY IS STRING LEN 20 ARRAY(5)
<p class="code">%starray is string len 20 array(5)
   
   
%RC = $Arr_Init(%STARRAY, '*** UNKNOWN ***')
%rc = $Arr_Init(%starray, '*** UNKNOWN ***')
</p>
</p></ol>
every element of %STARRAY is set to '*** UNKNOWN ***'.
 
==Products authorizing {{PAGENAMEE}}==
<ul class="smallAndTightList">
<ul class="smallAndTightList">
<li>[[Sirius functions]]</li>
<li>[[List of $functions|Sirius functions]]</li>
<li>[[Fast/Unload User Language Interface]]</li>
<li>[[Fast/Unload User Language Interface]]</li>
<li>[[Janus Open Client]]</li>
<li>[[Media:JoclrNew.pdf|Janus Open Client]]</li>
<li>[[Janus Open Server]]</li>
<li>[[Media:JosrvrNew.pdf|Janus Open Server]]</li>
<li>[[Janus Sockets]]</li>
<li>[[Janus Sockets]]</li>
<li>[[Janus Web Server]]</li>
<li>[[Janus Web Server]]</li>
<li>[[Japanese functions]]</li>
<li>Japanese functions</li>
<li>[[Sir2000 Field Migration Facility]]</li>
<li>[[Media:SirfieldNew.pdf|Sir2000 Field Migration Facility]]</li>
 
</ul>
</ul>
<p class="caption">Products authorizing $Arr_Init
</p>


[[Category:$Functions|$Arr_Init]]
[[Category:$Functions|$Arr_Init]]

Latest revision as of 16:08, 8 January 2018

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

  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