System.Array

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
namespace System
public sealed class Array

The Array class is equivalent to [#,#]@class. (See [#,#]@class for more information.) An instance of this class will only be created via the Synergy array syntax. It represents a 1-based array or, on .NET, a 0-based array with .ARRAY 0 declared. (See .ARRAY.) All of the method parameters or return values below that specify an index or dimension are 1-based unless .ARRAY 0 is specified, in which case they are 0-based. See “Variable references” in the Basic language elements topic for more information about array references.

Properties

Length

public Length

Returns the total number of elements in all dimensions of the array. (int)

Rank

public Rank

Returns the number of dimensions in the array. (int)

Methods

Clear

public static Clear(array, startindex, count), void

Sets elements in an array to 0, false, or null depending on the element type. When clearing a real array, the array behaves like one pseudo array whose rows are laid end to end. For example, a starting index of 6 in a [5,5] array will start clearing from index [2,1].

array

The array whose elements are to be cleared. (@Array)

startindex

The starting index of the range of elements to clear. (int)

count

The number of elements to clear. (int)

Copy

public static Copy(source, sourceindex, dest, destindex, count), void

Copies a range of elements in one array to another array. When copying between real arrays, each array behaves like one pseudo array whose rows are laid end to end. For example, a starting index of 6 in a [5,5] array will start copying from index [2,1].

source

The array containing the data to copy. (@Array)

sourceindex

The index in source at which copying begins. (int)

dest

The array that receives the copied data. (@Array)

destindex

The index in dest at which storing begins. (int)

count

The number of elements to copy. (int)

GetLength

public GetLength(dimension), int

Returns the length of the specified dimension (int).

GetValue

public GetValue(index), @*

Returns the value at the specified position in a single-dimension array (int).

IndexOf

public static IndexOf(array, value, startindex, count), int

Returns the first 1-based index position of the specified object in a single-dimension array. This method determines equality by calling the Equals() method of the Array element type.

array

The single-dimension array to search. (@Array)

value

The object to search for. (@*)

startindex

The index at which the search begins. (int)

count

The number of elements to search. (int)

LastIndexOf

public static LastIndexOf(array, value, startindex, count), int

Returns the 1-based index of the last occurrence of the specified object in a single-dimension array. This method determines equality by calling the Equals() method of the Array element type.

array

The single-dimension array to search. (@Array)

value

The object to search for. (@*)

startindex

The index at which the reverse search begins. (int)

count

The number of elements to search. (int)

SetValue

public SetValue(value, index), void

Sets the value (@*) at the specified array index (int) in a single-dimension array.

Examples

main
    record
        ;Declare real array of alphas of size 3
        myarray          ,[3]a3
        ;Declare dynamic array or string
        mydynamicarray   ,[#]string
        ;Counter variable to use in FOR loop
        counter          ,int

proc
    ;Open channel to terminal
    open(1, O, "TT:")

    ;Real array - populate and display
    for counter from 1 thru 3
      begin
        ;Add the values A, B, C to the array
        myarray[counter] = %char(64+counter)
        ;Writes
        writes(1, myarray[counter])
      end
    ;Dynamic array - declare with a number of elements then populate and display
    mydynamicarray = new string[3]

    for counter from 1 thru 3
      begin
        mydynamicarray[counter] = %char(96+counter)
        writes(1, mydynamicarray[counter])
      end
endmain