        $set rtncode-size"4" case reentrant intlevel"4"
       identification division.
       program-id. piexec.
      *
       environment division.
       configuration section.
       object-computer. any-thing.
      *
       data division.
       working-storage section.
       copy "javatypes.cpy".
       01 a            mf-jstring.
       01 lnk-end      jboolean.
       01 first-time    pic x value "Y".

      *
       01  di-1.
           02 di-term          pic x(33).
           02 di-pi            pic x(33).
      *
       01  di-2.
           02 di-term2         pic x(33).
           02 di-pi2           pic x(33).
      *
       01  work-area.
           02 pi               pic s9v9(31).
           02 term             pic s9v9(31).
           02 w                pic s9v9(31).
           02 n                pic 9(31).
           02 n1               pic 9(31).
           02 n2               pic 9(31).
           02 ed               pic -9.9(31).
      *
       procedure division.
             goback.

       entry "setup_picalc".
             move 0.5 to ed
             move ed to di-term
             move 3 to ed
             move ed to di-pi
             move 0.5 to pi
             move 0.5 to term
             move 3 to n
	     exit program returning 0.

       entry "calc_a_term".
             move n to n2
             subtract 2 from n2
             multiply n2 by n2
             multiply n2 by term
             move n to n1
             subtract 1 from n1
             multiply n by n1
             multiply 4 by n1
             divide n1 into term

             if term < 0.0000000000000000000000000000000000001 then
                 go to halt
             end-if

             add term to pi
             move pi to w
             multiply 6 by w
             move w to ed
             move ed to di-pi2
             move term to ed
             move ed to di-term2
             add 2 to n
             exit program returning JNI-FALSE.

       halt.
             exit program returning JNI-TRUE.
             goback.

        entry "getTerm".
                move length of di-term2 to len of a
                set ptr2string of a to address of di-term2
                exit program returning address of a.

        entry "getCurrentPI".
                move length of di-pi2 to len of a
                set ptr2string of a to address of di-pi2
                exit program returning address of a.


