      $set reentrant case intlevel"4"
      ****************************************************************
      * Copyright (C) 1997-2000 Micro Focus International Ltd.       *
      * All Rights Reserved.                                         *
      ****************************************************************
      *                                                              *
      * This COBOL program demonstrates how to read and update Java  *
      * Arrays from COBOL.                                           *
      *                                                              *
      *  Version History:                                            *
      *  1.0                        Created                          *
      *                                                              *
      ****************************************************************
       
       thread-local-storage section.
       copy "javatypes.cpy".
       01 mycount		jint.
       01 mycount2		jint.
       01 myloopcount		jint.
       01 mytmp1		pic x.
       01 mytmp2		pic x.
       01 myctmp1		jchar.
       01 myctmp2		jchar.
       
       linkage section.
       01 lnk-array             mf-jarray.
       01 lnk-int-element	jint occurs 1024 times.
       01 lnk-boolean-element	jboolean occurs 1024 times.
       01 lnk-float-element	jfloat occurs 1024 times.
       01 lnk-double-element	jdouble occurs 1024 times.
       01 lnk-short-element	jshort occurs 1024 times.
       01 lnk-long-element	jlong occurs 1024 times.
       01 lnk-byte-element	pic x(1024).
       01 lnk-character-element	jchar occurs 1024 times.

       procedure division.
               goback.

       entry "incints" using lnk-array.
       		set address of lnk-int-element(1)
                            to ptr2array of lnk-array
               	move 0 to mycount
               	perform until mycount equals no-of-elements of lnk-array
               		add 1 to mycount
                	add 10 to lnk-int-element(mycount)
               	end-perform
               	exit program returning 0.


       entry "incbools" using lnk-array.
               	set address of lnk-boolean-element(1)
                            to ptr2array of lnk-array
               	move 0 to mycount
               	perform until mycount equals no-of-elements of lnk-array
                	add 1 to mycount
                	if lnk-boolean-element(mycount) equal JNI-TRUE
                		move JNI-FALSE to
                			lnk-boolean-element(mycount)
                	else
                		move JNI-TRUE to
                			lnk-boolean-element(mycount)
                	end-if
               	end-perform
       exit program returning 0.


       entry "incfloats" using lnk-array.
       		set address of lnk-float-element(1)
                            to ptr2array of lnk-array
       		move 0 to mycount
       		perform until mycount equals no-of-elements of lnk-array
       			add 1 to mycount
       			add 0.5 to lnk-float-element(mycount)
       		end-perform
       exit program returning 0.


       entry "incdobs" using lnk-array.
       		move 0 to mycount
       		set address of lnk-double-element(1)
                            to ptr2array of lnk-array
       		perform until mycount equals no-of-elements of lnk-array
       			add 1 to mycount
       			add 10 to lnk-double-element(mycount)
       		end-perform
       exit program returning 0.

       entry "incshort" using lnk-array.
       		set address of lnk-short-element(1)
                            to ptr2array of lnk-array
       		move 0 to mycount
       		perform until mycount equals no-of-elements of lnk-array
       			add 1 to mycount
       			add 10 to lnk-short-element(mycount)
       		end-perform
       	exit program returning 0.

       entry "inclong" using lnk-array.
       		set address of lnk-long-element(1)
                            to ptr2array of lnk-array
       		move 0 to mycount
       		perform until mycount equals no-of-elements of lnk-array
       			add 1 to mycount
       			add 1000 to lnk-long-element(mycount)
       		end-perform
       	exit program returning 0.

       entry "revbytes" using lnk-array.
       		set address of lnk-byte-element
                            to ptr2array of lnk-array
       		move no-of-elements of lnk-array to mycount2
       		divide no-of-elements of lnk-array
                                      by 2 giving myloopcount
       		move 1 to mycount
       		perform until myloopcount equals zero
       			move lnk-byte-element(mycount:1) to mytmp1
       			move lnk-byte-element(mycount2:1) to mytmp2
       			move mytmp1 to lnk-byte-element(mycount2:1)
       			move mytmp2 to lnk-byte-element(mycount:1)
       			add 1 to mycount
       			subtract 1 from mycount2
       			subtract 1 from myloopcount
       		end-perform
       	exit program returning 0.

       entry "revchars" using lnk-array.
       		set address of lnk-character-element(1)
       				to ptr2array of lnk-array
       		move no-of-elements of lnk-array to mycount2
       		divide no-of-elements of lnk-array
                                      by 2 giving myloopcount
       		move 1 to mycount
       		perform until myloopcount equals zero
       			move lnk-character-element(mycount) to myctmp1
       			move lnk-character-element(mycount2) to myctmp2
       			move myctmp1 to lnk-character-element(mycount2)
       			move myctmp2 to lnk-character-element(mycount)
       			add 1 to mycount
       			subtract 1 from mycount2
       			subtract 1 from myloopcount
       		end-perform
       	exit program returning 0.


