Re: [Oorexx-devel] Question about calling an external routine

2009-01-25 Thread Rony G. Flatscher

rob...@garrettfamily.us wrote:
 (Apologies in advance if I've sent this to an inappropriate list)
  
 Is it possible to pass an instance of an object from an externally
 called routine back to the parent routine? If so, how?
  
 Example:
 Assume two separate REXX routines (separate files):  MAIN.rex and
 LOGGER.rex.
 I'd like to be able to, from MAIN, call LOGGER (passing it a file
 name), and have LOGGER create an instance of a stream object, open the
 file, and then pass the stream object back to MAIN at which point MAIN
 would be able to use the stream object to write to the file (or
 perhaps pass it to other external routines that would also be able to
 use it).
 I'm already doing this with LOGGER being a routine that is part of
 MAIN (both located in the same file), but I want to be able to break
 LOGGER out into a separate file.
  
 Is this possible?
Sure. Break out the routines add the keyword PUBLIC to each routine in
LOGGER.rex. Then, before using the public routines which now reside in
LOGGER.rex you need to CALL LOGGER, which will cause its public
routines (and public classes) to become visible. 'Thereafter you can
access all those routines as if they were defined in MAIN.rex.
  
 I've been writing and using REXX for many years in the mainframe
 environment so I'm quite familiar with the core language, but the
 facilities of ooREXX are still somewhat new to me.
If you are developing a logging facility for Rexx you might want to
learn about an ooRexx implementation of the log-framework that
originates from the Java world. Here's an article to that ooRexx
framework, demonstrating how to use it:
http://wi.wu-wien.ac.at/rgf/rexx/orx18/log4r/2007_orx18_log4rexx-20070517-article.pdf.
The ooRexx code of the log4rexx framework can be downloaded from:
http://wi.wu-wien.ac.at/rgf/rexx/orx18/log4r/log4rexx_20070521.zip, in
case it is of interest for you.

HTH,

---rony



--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword___
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel


Re: [Oorexx-devel] Question about calling an external routine

2009-01-25 Thread rob...@garrettfamily.us
Thanks for the reply, Rony.

I've been reading about the ::REQUIRES and ::ROUTINE directives in the doc
but so far haven't hit on the correct coding to get them working properly.
These directives/concepts don't exist in mainframe REXX so they're new to
me.
Is there a simple example I can look at that would reveal the proper coding
structure?

Also, thanks for the tip on the logging framework.

Thanks again,
Robert
  -Original Message-
  From: Rony G. Flatscher [mailto:rony.flatsc...@wu-wien.ac.at]
  Sent: Sunday, January 25, 2009 2:15 PM
  To: Open Object Rexx Developer Mailing List
  Subject:  Re: [Oorexx-devel] Question about calling an external routine



  rob...@garrettfamily.us wrote:
(Apologies in advance if I've sent this to an inappropriate list)

Is it possible to pass an instance of an object from an externally
called routine back to the parent routine? If so, how?

Example:
Assume two separate REXX routines (separate files):  MAIN.rex and
LOGGER.rex.
I'd like to be able to, from MAIN, call LOGGER (passing it a file name),
and have LOGGER create an instance of a stream object, open the file, and
then pass the stream object back to MAIN at which point MAIN would be able
to use the stream object to write to the file (or perhaps pass it to other
external routines that would also be able to use it).
I'm already doing this with LOGGER being a routine that is part of MAIN
(both located in the same file), but I want to be able to break LOGGER out
into a separate file.

Is this possible?
  Sure. Break out the routines add the keyword PUBLIC to each routine in
LOGGER.rex. Then, before using the public routines which now reside in
LOGGER.rex you need to CALL LOGGER, which will cause its public routines
(and public classes) to become visible. 'Thereafter you can access all those
routines as if they were defined in MAIN.rex.


I've been writing and using REXX for many years in the mainframe
environment so I'm quite familiar with the core language, but the facilities
of ooREXX are still somewhat new to me.
  If you are developing a logging facility for Rexx you might want to learn
about an ooRexx implementation of the log-framework that originates from the
Java world. Here's an article to that ooRexx framework, demonstrating how to
use it:
http://wi.wu-wien.ac.at/rgf/rexx/orx18/log4r/2007_orx18_log4rexx-20070517-a
rticle.pdf. The ooRexx code of the log4rexx framework can be downloaded
from: http://wi.wu-wien.ac.at/rgf/rexx/orx18/log4r/log4rexx_20070521.zip,
in case it is of interest for you.

  HTH,

  ---rony



--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword___
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel


Re: [Oorexx-devel] Question about calling an external routine

2009-01-25 Thread rob...@garrettfamily.us
Thanks for the push in the right direction, I actually have it working now.

One more quick question just because I'm being lazy at the moment:  in
LOGGER, is there a function/method I can call that will tell me 1) that it
is being invoked from a 'parent' calling routine (as opposed to being
started from a command prompt) and 2) what the name of that parent routine
is?

Thanks again for the help,
Robert
  -Original Message-
  From: Rony G. Flatscher [mailto:rony.flatsc...@wu-wien.ac.at]
  Sent: Sunday, January 25, 2009 4:46 PM
  To: Open Object Rexx Developer Mailing List
  Subject:  Re: [Oorexx-devel] Question about calling an external routine




  rob...@garrettfamily.us wrote:
Thanks for the reply, Rony.

I've been reading about the ::REQUIRES and ::ROUTINE directives in the
doc but so far haven't hit on the correct coding to get them working
properly.  These directives/concepts don't exist in mainframe REXX so
they're new to me.
Is there a simple example I can look at that would reveal the proper
coding structure?
  O.K., here's an example:

/* MAIN.rex */
call LOGGER   /* this will make LOGGER's public routines (and public
classes) accessible */
res=loggerDoSomething(hey, you!)
say res=res

streamObj=loggerCreateStream(myFilename.log)
streamObj~lineout(res)
streamObj~close


  Here's an example for the LOGGER.rex program:


/* LOGGER.rex */

::routine loggerDoSomething public  /* returns the reversed
argument-string */
   parse arg val
   return reverse(val)

::routine loggerCreateStream public /* creates a stream object with the
given filename */
   parse arg filename
   return .stream~new(filename)




Also, thanks for the tip on the logging framework.
  You are very welcome.

  ---rony

--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword___
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel