[Oorexx-devel] Question ad running multiple Rexx programs in the same interpreter instance from native (C++) code ...

2014-07-02 Thread Rony G. Flatscher
When analyzing WWW-browser script code embedded in (x)html files it is the case 
that the functions
of all scripts embedded in a (x)html file are available for scripts that are 
encountered and
executed later in a (x)html file.

To mimick this behaviour in ooRexx the (ooRexx) scripts get executed via the 
C++ interface in the
very same Rexx interpreter instance, expecting that all public routines and 
public classes of all
the Rexx scripts that sequentially get executed become available to later 
executing Rexx scripts,
which is not the case (like it was the case with the 3.x-interpreter and its 
WSH-support).

To demonstrate this the following (working) Java program executes two Rexx 
scripts, the first one
defines a public routine named test which gets also used in the first script, 
then later another
Rexx script (consisting just of one statement) executes that is supposed to 
access the public
routine test defined in the first script:

import org.apache.bsf.BSFException;
import org.apache.bsf.BSFManager;
import org.apache.bsf.BSFEngine;

public class JavaRunRexx_Test
{
public static void main (String args[]) throws BSFException
{
BSFManager mgr   =new BSFManager(); // create an instance 
of BSFManager
BSFEngine  rexxEngine=mgr.loadScriptingEngine(rexx);  // load the 
Rexx engine

System.out.println(--- 1 (Java): run Rexx package that defines a 
public method 'test()'...);
// Rexx code to run
String */rexxCode= say 'test():' test()  ; +//
// ::routine test public ; +//
//   return 'from routine test()'; ;/*
rexxEngine.apply (JavaRunRexx_Test-01, 0, 0, rexxCode, null, 
null);


System.out.println(--- 2 (Java): run Rexx code that uses public 
method 'test()' defined for prior run...);
*/rexxCode= say 'test():' test() /**/ ; ;/*
rexxEngine.apply (JavaRunRexx_Test-02, 0, 0, rexxCode, null, 
null);

mgr.terminate();// make sure that the Rexx interpreter instance 
gets terminated!
}
}

Running the above Java program creates a Rexx interpreter instance which 
executes two Rexx scripts,
yielding the following output:

F:\work\svn\bsf4oorexx\trunk\samples\Javajava JavaRunRexx_Test
--- 1 (Java): run Rexx package that defines a public method 'test()'...
*/test(): from routine test()/*
--- 2 (Java): run Rexx code that uses public method 'test()' defined for 
prior run...
Exception in thread main org.rexxla.bsf.engines.rexx.RexxException: 
BSF4ooRexx/routine/jniRexxRunProgram(), error 9:
 */1 *-* say 'test():' test()  ;/**/
/**/Error 43 running JavaRunRexx_Test-02 line 1:  Routine not found/**/
/**/Error 43.1:  Could not find routine TEST/*
at org.rexxla.bsf.engines.rexx.RexxAndJava.jniRexxRunProgram(Native 
Method)
at org.rexxla.bsf.engines.rexx.RexxEngine.apply(RexxEngine.java:935)
at JavaRunRexx_Test.main(JavaRunRexx_Test.java:54)

Judging from the error message when running the second Rexx script its package 
does not have the
public routines of the first Rexx script available (already executed in the 
same Rexx interpreter
instance).

How could one make sure from native/C++ code that the second (or any later 
executed) Rexx script can
see all public routines (and public classes) of any Rexx programs that were 
already executed in the
same Rexx interpreter instance?

---rony

--
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft___
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel


Re: [Oorexx-devel] Question ad running multiple Rexx programs in the same interpreter instance from native (C++) code ...

2014-07-02 Thread Rick McGuire
On Wed, Jul 2, 2014 at 12:04 PM, Rony G. Flatscher rony.flatsc...@wu.ac.at
wrote:

  When analyzing WWW-browser script code embedded in (x)html files it is
 the case that the functions of all scripts embedded in a (x)html file are
 available for scripts that are encountered and executed later in a (x)html
 file.

 To mimick this behaviour in ooRexx the (ooRexx) scripts get executed via
 the C++ interface in the very same Rexx interpreter instance, expecting
 that all public routines and public classes of all the Rexx scripts that
 sequentially get executed become available to later executing Rexx scripts,
 which is not the case (like it was the case with the 3.x-interpreter and
 its WSH-support).


Yes, that was the way it worked...and it was implemented via some pretty
horrible hacks.  It went beyond that, as all of the script fragments shared
a common variable space (also implemented via some pretty horrible hacks).


 To demonstrate this the following (working) Java program executes two Rexx
 scripts, the first one defines a public routine named test which gets also
 used in the first script, then later another Rexx script (consisting just
 of one statement) executes that is supposed to access the public routine
 test defined in the first script:

 import org.apache.bsf.BSFException;
 import org.apache.bsf.BSFManager;
 import org.apache.bsf.BSFEngine;

 public class JavaRunRexx_Test
 {
 public static void main (String args[]) throws BSFException
 {
 BSFManager mgr   =new BSFManager(); // create an instance of 
 BSFManager
 BSFEngine  rexxEngine=mgr.loadScriptingEngine(rexx);  // load the 
 Rexx engine

 System.out.println(--- 1 (Java): run Rexx package that defines a 
 public method 'test()'...);
 // Rexx code to run
 String *rexxCode= say 'test():' test()  ; +
  ::routine test public ; +
return 'from routine test()'; ;*
 rexxEngine.apply (JavaRunRexx_Test-01, 0, 0, rexxCode, null, null);


 System.out.println(--- 2 (Java): run Rexx code that uses public 
 method 'test()' defined for prior run...);
 *rexxCode= say 'test():' test() ** ; ;*
 rexxEngine.apply (JavaRunRexx_Test-02, 0, 0, rexxCode, null, null);

 mgr.terminate();// make sure that the Rexx interpreter instance 
 gets terminated!
 }
 }

  Running the above Java program creates a Rexx interpreter instance which
 executes two Rexx scripts, yielding the following output:

 F:\work\svn\bsf4oorexx\trunk\samples\Javajava JavaRunRexx_Test--- 1 (Java): 
 run Rexx package that defines a public method 'test()'...*test(): from 
 routine test()*--- 2 (Java): run Rexx code that uses public method 'test()' 
 defined for prior run...
 Exception in thread main org.rexxla.bsf.engines.rexx.RexxException: 
 BSF4ooRexx/routine/jniRexxRunProgram(), error 9:
  *1 *-* say 'test():' test()  ;**Error 43 running 
 JavaRunRexx_Test-02 line 1:  Routine not found**Error 43.1:  Could not find 
 routine TEST*
 at org.rexxla.bsf.engines.rexx.RexxAndJava.jniRexxRunProgram(Native 
 Method)
 at org.rexxla.bsf.engines.rexx.RexxEngine.apply(RexxEngine.java:935)
 at JavaRunRexx_Test.main(JavaRunRexx_Test.java:54)

  Judging from the error message when running the second Rexx script its
 package does not have the public routines of the first Rexx script
 available (already executed in the same Rexx interpreter instance).

 How could one make sure from native/C++ code that the second (or any later
 executed) Rexx script can see all public routines (and public classes) of
 any Rexx programs that were already executed in the same Rexx interpreter
 instance?


I haven't tried this, but I suspect if you used the addPackage method to
add the package from the first script to the package of the second script
before calling it, this might work.  You might even be able to create a
master package that each script gets added to, although that might end up
with some recursion problems.

Rick


 ---rony



 --
 Open source business process management suite built on Java and Eclipse
 Turn processes into business applications with Bonita BPM Community Edition
 Quickly connect people, data, and systems into organized workflows
 Winner of BOSSIE, CODIE, OW2 and Gartner awards
 http://p.sf.net/sfu/Bonitasoft
 ___
 Oorexx-devel mailing list
 Oorexx-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/oorexx-devel


--
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner 

Re: [Oorexx-devel] Question ad running multiple Rexx programs in the same interpreter instance from native (C++) code ...

2014-07-02 Thread Rony G. Flatscher

On 02.07.2014 18:17, Rick McGuire wrote:

 On Wed, Jul 2, 2014 at 12:04 PM, Rony G. Flatscher rony.flatsc...@wu.ac.at
 mailto:rony.flatsc...@wu.ac.at wrote:

 When analyzing WWW-browser script code embedded in (x)html files it is 
 the case that the
 functions of all scripts embedded in a (x)html file are available for 
 scripts that are
 encountered and executed later in a (x)html file.

 To mimick this behaviour in ooRexx the (ooRexx) scripts get executed via 
 the C++ interface in
 the very same Rexx interpreter instance, expecting that all public 
 routines and public classes
 of all the Rexx scripts that sequentially get executed become available 
 to later executing
 Rexx scripts, which is not the case (like it was the case with the 
 3.x-interpreter and its
 WSH-support).


 Yes, that was the way it worked...and it was implemented via some pretty 
 horrible hacks.  It went
 beyond that, as all of the script fragments shared a common variable space 
 (also implemented via
 some pretty horrible hacks).
The idea is to define an entry HOST (a Rexx directory) in .local to not 
interfere with/pollute the
variable space. E.g. an object named document would have an entry named 
document in .host and
could then be referenced wiht .host~document, which should make it explicit 
that the entry was
defined by the script's host program. And it looks like a reasonable short 
statement for that purpose.

(And if someone wishes to access those entries in an easier manner one could do 
an explicit
.local~putAll(.host) to turn those entries into environment symbols 
themselves. Then one could use
.document instead, still not interfering with/polluting with the varialbe 
space, however running
the risk to interfere with/polluting entries in .local that may have the same 
name as a host
variable.)


  

 To demonstrate this the following (working) Java program executes two 
 Rexx scripts, the first
 one defines a public routine named test which gets also used in the first 
 script, then later
 another Rexx script (consisting just of one statement) executes that is 
 supposed to access the
 public routine test defined in the first script:

 import org.apache.bsf.BSFException;
 import org.apache.bsf.BSFManager;
 import org.apache.bsf.BSFEngine;

 public class JavaRunRexx_Test
 {
 public static void main (String args[]) throws BSFException
 {
 BSFManager mgr   =new BSFManager(); // create an 
 instance of BSFManager
 BSFEngine  rexxEngine=mgr.loadScriptingEngine(rexx);  // 
 load the Rexx engine

 System.out.println(--- 1 (Java): run Rexx package that 
 defines a public method 'test()'...);
 // Rexx code to run
 String */rexxCode= say 'test():' test()  ; +//
 // ::routine test public ; +//
 //   return 'from routine test()'; ;/*
 rexxEngine.apply (JavaRunRexx_Test-01, 0, 0, rexxCode, 
 null, null);


 System.out.println(--- 2 (Java): run Rexx code that uses 
 public method 'test()' defined for prior run...);
 */rexxCode= say 'test():' test() /**/ ; ;/*
 rexxEngine.apply (JavaRunRexx_Test-02, 0, 0, rexxCode, 
 null, null);

 mgr.terminate();// make sure that the Rexx interpreter 
 instance gets terminated!
 }
 }

 Running the above Java program creates a Rexx interpreter instance which 
 executes two Rexx
 scripts, yielding the following output:

 F:\work\svn\bsf4oorexx\trunk\samples\Javajava JavaRunRexx_Test
 --- 1 (Java): run Rexx package that defines a public method 
 'test()'...
 */test(): from routine test()/*
 --- 2 (Java): run Rexx code that uses public method 'test()' defined 
 for prior run...
 Exception in thread main org.rexxla.bsf.engines.rexx.RexxException: 
 BSF4ooRexx/routine/jniRexxRunProgram(), error 9:
  */1 *-* say 'test():' test()  ;/**/
 /**/Error 43 running JavaRunRexx_Test-02 line 1:  Routine not 
 found/**/
 /**/Error 43.1:  Could not find routine TEST/*
 at 
 org.rexxla.bsf.engines.rexx.RexxAndJava.jniRexxRunProgram(Native Method)
 at 
 org.rexxla.bsf.engines.rexx.RexxEngine.apply(RexxEngine.java:935)
 at JavaRunRexx_Test.main(JavaRunRexx_Test.java:54)

 Judging from the error message when running the second Rexx script its 
 package does not have
 the public routines of the first Rexx script available (already executed 
 in the same Rexx
 interpreter instance).

 How could one make sure from native/C++ code that the second (or any 
 later executed) Rexx
 script can see all public routines (and public classes) of any Rexx 
 programs that were already