You are on page 1of 3

NAME: RENTORIA, BEN MIGUEL L.

SECTION/COURSE: TA1 BSIT


SUBJECT: CC02

CREATING ARRAYS
- Arrays are declared by using the Array type name, optionally followed by "of"
and the type of the elements. If the element type is omitted, it is set by default
to ANY.
Local Array of Number &MYARRAY;
Local Array &ARRAYANY;
Arrays can be composed of any valid PeopleCode data type, such as string,
record, number, date, and so on.
PeopleSoft recommends you declare every object you use in PeopleCode.
This provides some syntax checking when you save PeopleCode. It’s better to
find out that you misspelled the name of a method or property at design time,
rather than at runtime!
Arrays can be declared as Local, Global, or Component, just like any other
PeopleTools object.
Arrays can be created with one or more dimensions. An array with more than
one dimension is called an array of arrays. The dimension of an array is the
number of Array type names in the declaration. This is also called the depth of
an array. The maximum depth of a PeopleCode array is 15 dimensions.
In the following example, &MYARRAY has three dimensions, and &MYA2 has
two dimensions.
Local Array of Array of Array of Number &MYARRAY;
Local Array of Array &MYA2;
An array must always have a consistent dimension. This means that in a one-
dimensional array none of the elements can be an array, in a two-dimensional
array all of the elements must be one-dimensional arrays, and so on.
After you declare an array, use one of the built-in array functions to instantiate
it and return an object reference to it. For example, the following creates an
array containing one element of type &TEMP, whatever data type &TEMP
may be.
&MYARRAY = CreateArray(&TEMP);
Or you can use the CreateArrayRept function to instantiate an array. The Rept
stands for repeat. CreateArrayRept creates an array that contains the number
of copies you specify of a particular value. The following code creates an
array with three copies of the string &MYSTRING. This does not create a
three-dimensional array, but rather creates an array that’s already populated
with three elements of data (Len = 3), each of which contain the same string
(&MYSTRING).
&MYARRAY = CreateArrayRept(&MYSTRING, 3);
An array object can be assigned to an array variable. Array objects can be
passed from and returned to any kind of PeopleCode function:
ANewFunc (&myarray);
MyFunc (&myarray);
&MyArray = YourFunc("something");
For example, the ReturnToServer function returns an array of nodes to which
a message can be published.
Elements in an array are specified by providing a bracketed subscript after the
array object reference:
&MyArray[1] = 123;
&temp = &memory[1][2][3];
&temp = &memory[1, 2, 3]; /* Same as preceding line. */
MyFunc(&MyArray[7]);
MyFunc(10)[15] = "a string";
To access data in a two-dimensional array, you must specify both indexes.
The following accesses the second item in the first subarray:
&VALUE = &DOUBLE[1][2];
You receive an error if you use a zero or negative index in an array.
Accessing an array element whose index is larger than the last array element
is also an error, but storing to such an index extends the array. Any
intervening elements between the former last element and the new last
element are assigned a value based on the element type of the array. This is
the same value as an unassigned variable of that type.
An array is an object, which means that assignments to an array are the same
as for any other object. An array variable can be assigned the distinguished
value NULL, which indicates the absence of any array value.
Array variables are supported for all scopes. This means that you can have
local, global, and Component array variables.

DYNAMIC ARRAYS
- A dynamic array, growable array, resizable array, dynamic table, mutable
array, or array list is a random access, variable-size list data structure that
allows elements to be added or removed. It is supplied with standard libraries
in many modern mainstream programming languages. Dynamic arrays
overcome a limit of static arrays, which have a fixed capacity that needs to be
specified at allocation.
A dynamic array is not the same thing as a dynamically allocated array, which
is an array whose size is fixed when the array is allocated, although a
dynamic array may use such a fixed-size array as a back end.

MULTI - DIMENSIONAL ARRAYS

- Multidimensional arrays are an extension of 2-D matrices and use additional


subscripts for indexing. A 3-D array, for example, uses three subscripts. The
first two are just like a matrix, but the third dimension represents pages or
sheets of elements
.
JAGGED ARRAYS

- A jagged array is an array whose elements are arrays. The elements of


a jagged array can be of different dimensions and sizes. A jagged array is
sometimes called an "array of arrays." A special type of array is introduced in
C#. A Jagged Array is an array of an array in which the length of
each array index can differ.

THE ARRAY CLASS


- Provides methods for creating, manipulating, searching, and sorting arrays,
thereby serving as the base class for all arrays in the common language
runtime.
The Array class is the base class for all the arrays in C#. It is defined in
the System namespace. The Array class provides various properties and
methods to work with arrays.

You might also like