36 lines
1.1 KiB
Text
36 lines
1.1 KiB
Text
import COM.ibm.netrexx.process.
|
|
|
|
class JensensDevice
|
|
|
|
properties static
|
|
interpreter=NetRexxA
|
|
exp=Rexx ""
|
|
termMethod=Method
|
|
|
|
method main(x=String[]) static
|
|
say sum('i',1,100,'1/i')
|
|
|
|
method sum(i,lo,hi,term) static SIGNALS IOException,NoSuchMethodException,IllegalAccessException,InvocationTargetException
|
|
sum=0
|
|
loop iv=lo to hi
|
|
sum=sum+termeval(i,iv,term)
|
|
end
|
|
return sum
|
|
|
|
method termeval(i,iv,e) static returns Rexx SIGNALS IOException,NoSuchMethodException,IllegalAccessException,InvocationTargetException
|
|
if e\=exp then interpreter=null
|
|
exp=e
|
|
|
|
if interpreter=null then do
|
|
termpgm='method term('i'=Rexx) static returns rexx;return' e
|
|
fw=FileWriter("termpgm.nrx")
|
|
fw.write(termpgm,0,termpgm.length)
|
|
fw.close
|
|
interpreter=NetRexxA()
|
|
interpreter.parse([String 'termpgm.nrx'],[String 'nocrossref'])
|
|
termClass=interpreter.getClassObject(null,'termpgm')
|
|
classes=[interpreter.getClassObject('netrexx.lang', 'Rexx', 0)]
|
|
termMethod=termClass.getMethod('term', classes)
|
|
end
|
|
|
|
return Rexx termMethod.invoke(null,[iv])
|