beautypg.com

Get-array-length method (object method), Explanation, Syntax – FUJITSU J Adapter Class Generator User Manual

Page 68: Parameter and return value, Get-array-element method (object method)

background image

68 Chapter 5. Adapter Class Reference

...
REPOSITORY.
CLASS JA-2-INT AS "JA-2-int"
CLASS JA-1-INT AS "JA-1-int"
...
01 anArray OBJECT REFERENCE JA-2-INT.
01 wArray OBJECT REFERENCE JA-1-INT.
...
INVOKE JA-2-INT "NEW-ARRAY" USING n RETURNING anArray. [1]
PERFORM VARYING I FROM 0 BY 1 UNTIL I >= n
INVOKE JA-1-INT "NEW-ARRAY" USING m RETURNING wArray [2]
INVOKE anArray "SET-ARRAY-ELEMENT" USING I wArray [3]
END-PERFORM.
SET wArray TO NULL.

1. A two-dimensional array object of int is generated (number of elements = n).
2. A one-dimensional array object of int is generated (number of elements = m).
3. The one-dimensional array generated in [2] is set in each element of the first

dimension of anArray.

GET-ARRAY-LENGTH method (object method)

Explanation
This method returns the number of elements of an array object.
Syntax
INVOKE

anObject

"GET-ARRAY-LENGTH" RETURNING

elmNum

Parameter and return value
• anObject

Specifies the array object from which the number of elements is obtained.

• elmNum (attribute: PIC S9(9) COMP-5)

Returns the number of elements of an array.

GET-ARRAY-ELEMENT method (object method)

Explanation
This method fetches an element from an array object.
Syntax
INVOKE

anObject

"GET-ARRAY-ELEMENT" USING inx RETURNING

elemValue

Parameter and return value
• anObject

Specifies the array object from which an element is to be fetched.

• inx (attribute: PIC S9(9) COMP-5)

Specifies the subscript of the element to be fetched. The subscript begins

from 0.

• elemValue (attribute: Array element type)

Returns the value of the array element fetched.