IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Function to include source into a rexx


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
valyk

Active User


Joined: 16 Apr 2008
Posts: 104
Location: South Carolina

PostPosted: Thu Dec 23, 2010 12:08 am
Reply with quote

Has anyone written an external function that will dynamically include source into a rexx program at execution time? Something like the #include function in C.

I scanned through the CBT files, and searched this forum and google and could not find anything.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Dec 23, 2010 12:14 am
Reply with quote

nobody wrote it because TSO/E REXX does not support it!
Back to top
View user's profile Send private message
valyk

Active User


Joined: 16 Apr 2008
Posts: 104
Location: South Carolina

PostPosted: Thu Dec 23, 2010 12:18 am
Reply with quote

Surely it is possible. Just like TSO/E Rexx does not support VSAM, but there are external functions that make it possible.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Dec 23, 2010 12:42 am
Reply with quote

Quote:
Surely it is possible

since You are so sure post the reference
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Dec 23, 2010 12:49 am
Reply with quote

Hello,

Quote:
Has anyone written an external function that will dynamically include source into a rexx program at execution time?
What you could do is create the complete rexx "on the fly" and execute it . . .

Why would you believe that whoever wrote the rexx internals used everything from some other language(s) compiler(s)?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Dec 23, 2010 12:54 am
Reply with quote

if the rexx application is so convoluted then the best approach is to use the rexx compiler
which indeed provides the include function

as far as the possibility to include on the fly something at the source level,
I strongly confirm that external/internal/tangent noo way to do it

but if on the other side You are looking for some kind of preprocessor along the lines of the C preprocessor

#include
#define
#if / #ifdef
#else
#endif

there are a few around... PREPROCESSORS i said!
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Dec 23, 2010 1:10 am
Reply with quote

follow on ...
the only standards compliant REXX which provides something similar to the include directive
is ooRexx ( Object Oriented Rexx ) available on the major PC platforms zLinux and zOS/USS

using in an OO structured rexx script the ::requires directive as per
Quote:
The ::REQUIRES Directive

You use the ::REQUIRES directive when a program needs access to the classes and objects of another program. This directive has the following form:

::REQUIRES program_name
::REQUIRES directives are processed before other directives and the order of the ::REQUIRES directives determines the search order for the classes and routines defined in the named programs.

Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Thu Dec 23, 2010 1:16 am
Reply with quote

Perhaps you could include an EXECIO to retrieve the external source into a variable, then use the INTERPRET statement to "dynamically" invoke the contents of that variable?

"INTERPRET processes instructions that have been built dynamically by evaluating expression. The expression is evaluated and is then processed (interpreted) just as though the resulting string were a line inserted into the program (and bracketed by a DO; and an END;). Any instructions (including INTERPRET instructions) are allowed, but note that constructions such as DO...END and SELECT...END must be complete. For example, a string of instructions being interpreted cannot contain a LEAVE or ITERATE instruction (valid only within a repetitive DO loop) unless it also contains the whole repetitive DO...END construct. A semicolon is implied at the end of the expression during execution, if one was not supplied."
Back to top
View user's profile Send private message
valyk

Active User


Joined: 16 Apr 2008
Posts: 104
Location: South Carolina

PostPosted: Thu Dec 23, 2010 1:20 am
Reply with quote

I tried looking for a manual on how the Rexx Interpret works, but I could not find anything.

I was assuming that the interpreter creates an internal table with each routine that it accesses. I was thinking that you could append the included routine to the table. That would give the exec 'addressibility' to the routine. Then when you reference the routine, it would find your included routine in the table.

But I am just taking a wild shot in the dark...
Back to top
View user's profile Send private message
Josh Keller

New User


Joined: 08 Oct 2007
Posts: 36
Location: Columbia, SC

PostPosted: Thu Dec 23, 2010 2:22 am
Reply with quote

You can call an external routine located in your SYSPROC libs.

As Enrico said, you'd need to have a preprocessor to expand your code into a new rexx which would become your exec.
I imagine a CM tool like Endevor could be setup with a REXX processor group that ran a custom preprocessor looking for #INCLUDE statements and expanding that code from common libraries before adding it to the SYSPROC libs.



From the manual:

INTERPRET processes instructions that have been built dynamically by
evaluating expression.

The expression is evaluated and is then processed (interpreted) just as
though the resulting string were a line inserted into the program (and
bracketed by a DO; and an END;).

Any instructions (including INTERPRET instructions) are allowed, but note
that constructions such as DO...END and SELECT...END must be complete.
For example, a string of instructions being interpreted cannot contain a
LEAVE or ITERATE instruction (valid only within a repetitive DO loop)
unless it also contains the whole repetitive DO...END construct.

A semicolon is implied at the end of the expression during execution, if
one was not supplied.

Example:

data='FRED'
interpret data '= 4'
/* Builds the string "FRED = 4" and */
/* Processes: FRED = 4; */
/* Thus the variable FRED is set to "4" */

Example:

data='do 3; say "Hello there!"; end'
interpret data /* Displays: */
/* Hello there! */
/* Hello there! */
/* Hello there! */
Back to top
View user's profile Send private message
valyk

Active User


Joined: 16 Apr 2008
Posts: 104
Location: South Carolina

PostPosted: Thu Dec 23, 2010 2:30 am
Reply with quote

Josh Keller wrote:
You can call an external routine located in your SYSPROC libs.

As Enrico said, you'd need to have a preprocessor to expand your code into a new rexx which would become your exec.
I imagine a CM tool like Endevor could be setup with a REXX processor group that ran a custom preprocessor looking for #INCLUDE statements and expanding that code from common libraries before adding it to the SYSPROC libs.



From the manual:

INTERPRET processes instructions that have been built dynamically by
evaluating expression.

The expression is evaluated and is then processed (interpreted) just as
though the resulting string were a line inserted into the program (and
bracketed by a DO; and an END;).

Any instructions (including INTERPRET instructions) are allowed, but note
that constructions such as DO...END and SELECT...END must be complete.
For example, a string of instructions being interpreted cannot contain a
LEAVE or ITERATE instruction (valid only within a repetitive DO loop)
unless it also contains the whole repetitive DO...END construct.

A semicolon is implied at the end of the expression during execution, if
one was not supplied.

Example:

data='FRED'
interpret data '= 4'
/* Builds the string "FRED = 4" and */
/* Processes: FRED = 4; */
/* Thus the variable FRED is set to "4" */

Example:

data='do 3; say "Hello there!"; end'
interpret data /* Displays: */
/* Hello there! */
/* Hello there! */
/* Hello there! */


This is how I currently 'include' source code into my exec's but it would me nice if there were an external function to include the source at execution.
Back to top
View user's profile Send private message
valyk

Active User


Joined: 16 Apr 2008
Posts: 104
Location: South Carolina

PostPosted: Thu Dec 23, 2010 2:32 am
Reply with quote

valyk wrote:
I tried looking for a manual on how the Rexx Interpret works, but I could not find anything.


I meant to type Interpreter. Is there a manual explaining the inner workings of the Rexx Interpreter?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Dec 23, 2010 3:54 am
Reply with quote

Hello,

Quote:
I meant to type Interpreter.
Yup, and i'm sure what almost all of us read icon_smile.gif

There probably is, but i suspect it would be IBM proprietary information. . .
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Dec 23, 2010 4:15 am
Reply with quote

if You want to have an idea of how a rexx interpreter works You can have a look at the sources starting from here

sourceforge.net/projects/oorexx/

sourceforge.net/projects/regina-rexx/
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top