Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#23 #include like feature for Regina Rexx?

open
nobody
None
5
2004-05-07
2004-05-07
Anonymous
No

Hi,

As I'm building Rexx "applets", I'm creating reusable
portions of code that would do wonderfully if they
could be INCLUDEd in each Rexx app, substituted every
time the app was run. The most obvious choice to me is
to insert a preprocessor #INCLUDE directive, and have
Regina Rexx automatically invoke a preprocessor. After
some online searching, there does not appear to be a
preprocessor option, so at this point all I can think
of to do is "wrap" each Regina Rexx invocation in a
batch file that invokes a preprocessor, saves the
preprocessed output as a temp file, runs it, then
deletes it. This causes PARSE SOURCE problems in
getting the original appname/location, and while I can
do some theatrics in the batch file to handle this
(saving old file, renaming temp file as old file,
restoring old file), there could be other issues I
haven't thought of yet...

Is there a better way to do this? My thoughts thus far:

1. Does/should Regina Rexx automatically invoke a
preprocessor like C compilers do? I note that, in
version 3.3, Regina ignores #INCLUDE directives, yet
does NOT give an error message (as opposed to, for
example, #IFDEF and #DEFINE).

2. Is there some way to use "macros"? I see much about
them in the docs, but I confess I'm not sure what the
word means in a Rexx context or how to actually set it up.

3. I also see a lot about pulling functions from DLL
libraries, but have been unable to find anything in the
docs or Google searches as to how to BUILD one of these
libraries. At any rate, I want code snippets to be
inserted, not be limited to entire functions, so this
may not be as useful...

4. Anything other ideas?

Your thoughts and assitance appreciated!

Chris Niggeler
cniggeler@yahoo.com

Discussion

  • Logged In: YES
    user_id=371416

    QUESTION:
    1. Does/should Regina Rexx automatically invoke a
    preprocessor like C compilers do? I note that, in
    version 3.3, Regina ignores #INCLUDE directives, yet
    does NOT give an error message (as opposed to, for
    example, #IFDEF and #DEFINE).

    ANSWER 1:
    Most Rexx language processors do not support an INCLUDE
    feature. It is not part of the Rexx standard. The only
    Rexx language processor that I am aware of which provides
    this type of facility is IBM's mainframe Rexx compiler.
    (Note: I am not pleased with the manner in which the Rexx
    compiler implements %INCLUDE, but that's another discussion
    ;-). I agree that addition of %INCLUDE would be a wonderful
    enhancement to Regina (or any other Rexx processor). I have
    no idea why Regina would treat #INCLUDE any differently from
    #DEFINE .. its probably a bug.

    QUESTION:
    2. Is there some way to use "macros"? I see much about
    them in the docs, but I confess I'm not sure what the
    word means in a Rexx context or how to actually set it up.

    ANSWER 2:
    You're thinking about macros like an application programmer,
    where macros are used to generate sequences of instructions
    in some other language (assembly, C, etc). The term macros,
    when used in a Rexx context is usually somewhat different.
    Rexx is generally used as a language to write macros *in*.
    When you write a macro for MS Excel or Word, for example,
    you use the VBS programming language. There are a number of
    applications (Editors, 3270 Emulators, testing products,
    etc) which use Rexx as the language for their macros. In
    addition, you can write such "scripts" for the host
    operating system. Rexx is a far better scripting/macro
    language than DOS/Window .BAT (even with the recent
    improvements).

    There is an entire section in the Regina manual on how to
    set up an application such that it uses Rexx as the
    scripting/macro language.

    QUESTION:
    3. I also see a lot about pulling functions from DLL
    libraries, but have been unable to find anything in the
    docs or Google searches as to how to BUILD one of these
    libraries. At any rate, I want code snippets to be
    inserted, not be limited to entire functions, so this
    may not be as useful...

    ANSWER 3:
    A function library for Regina would have to be built as a
    .DLL -- see the Patrick McPhee rexxutil.dll
    (http://www.interlog.com/~ptjm/software.html "RegUtil"
    package) for an example of how this is done.

    As you recognized, a function library is not be exactly what
    you need. However, you may consider creating external Rexx
    functions to perform the same operations as the code you
    wish to include. This is not always feasible, but you
    should give it some consideration. You may want to post an
    example of something you are INCLUDE-ing for discussion;
    maybe someone here has an idea or two.

    QUESTION:
    4. Anything other ideas?

    ANSWER 4:
    No, other than to observe that you are doing this the only
    way practical with Regina (e.g. using an independent
    preprocessor. Lack of %INCLUDE is a shortcoming in standard
    Rexx which many of us lament.

     
  • Bill Comegys
    Bill Comegys
    2010-12-28

    Hi, I like and support the the idea it would be very helpful to me.
    I would like to make a suggestion.
    INCLUDE("[path]filename" [, stem])
    Where optional path is the path to the file, otherwise searches for the filename in the directory the calling program was started in, if not found then where the REXX interpreter was loaded, if not found produce an error message. INCLUDE file not found.
    filename is the file containing the functions and procedures.
    stem is a stem (array) containing the functions and procedures you would like loaded in the filname if the comma and stem is omitted all functions and procedures are loaded from the filename. If a function or procedure is in the stem variable and not in the include file an error message should also be produced.
    Thanks