Calling REXX programs from within an assembler program 
Author Message
 Calling REXX programs from within an assembler program

   Is there any simple way to call the REXX interpreter from within an
assembler program and explicitly define which addressing environment the
REXX routine is to use, regarldless of its file-type?   In other words,
I have a REXX routine with a filetype of J2CMDEX.  I want it to be
called so that it already addresses commands to the CMS environment
without having to use the ADDRESS statement to do it.  I believe CMS
Pipelines does this, but haven't been able to find anything in the
manuals (yet) that tells me how to do it.  Thanks in advance for any
help.

 - David



Mon, 18 Mar 1996 18:31:38 GMT  
 Calling REXX programs from within an assembler program

Quote:
David Young writes:
>   Is there any simple way to call the REXX interpreter from within an
>assembler program and explicitly define which addressing environment the
>REXX routine is to use, regarldless of its file-type?   In other words,
>I have a REXX routine with a filetype of J2CMDEX.  I want it to be
>called so that it already addresses commands to the CMS environment
>without having to use the ADDRESS statement to do it.  I believe CMS
>Pipelines does this, but haven't been able to find anything in the
>manuals (yet) that tells me how to do it.  Thanks in advance for any
>help.

> - David

In order to run a REXX program and have its default host environment be
different than its file type, you need to specify the default environment
name in words 3 and 4 of the file block extension. Place the file block
address is in word 4  of the EPLIST (extended parameter list) when the
REXX program is invoked. The file block contains a file id (name, type,
and mode) followed by the length of the file block extension (which
may be 0 if there is no extension), followed by the optional file
block extension. This is described in the VM System Product Interpreter
Reference manual, chapter 9, System Interfaces.
I've included an example REXX program and assembler program which
demonstrate how this works.

I'm curious as to why this is a problem, since the only way I know to
invoke a REXX program with a file type other than EXEC is via a
file block, and the only doc for file block's I know of is the SPI
manual, where the file block extension is also described. Is there
another way to call a REXX program with a file type other than EXEC?

======== Cut here for the example REXX program DIFFENV GORP
/*
  A REXX program to be called from assembler program TESTENV.
  It will be called with a default host environment of 'ENV'.
  This REXX program should be named DIFFENV GORP, because that
  is how TESTENV will call it.
*/
say 'arg 1=/'arg(1)'/'
say 'default host address=/'address()'/'
parse source s
say 'parse source info=/'s'/'
'Calling host environment ENV'
say 'RC='RC
''
say 'RC='RC
======== Cut here for the example assembler program TESTENV ASSEMBLE
*
*  Invoke a REXX program whose default environment is different
*  from its file type.  The REXX program then invokes a sub-command
*  entry point in this assembler program.
*
*  Written by: Paul Wolberg
*
*  Assemble using either assembler F (the ASSEMBLE command) or
*  assembler H (the HASM command).
*
*  The following macros are used. They require that the DMSGPI macro
*  library is part of the macro search list (GLOBAL MACLIB DMSGPI)
*  They are described in VM/XA CMS Application Program
*  Development Reference (SC23-0402-0)
*
*  CMSCALL - supervisor assisted linkage
*  CMSRET  - return from a program invoked by CMSCALL
*  SUBCOM  - create a sub-command entry point
*  APPLMSG - display messages on the console
*
TESTENV  CSECT
         USING *,12    R12 is base register
*
*  Create a sub-command entry point whose name is different than
*  the called REXX program's file type, so we have a sub-command
*  environment to access from the REXX program.
*
         SUBCOM SET,NAME='ENV',ENTRY=ENV
*
*  Call the REXX program using CMSCALL. Word 4 of the EPLIST
*  points to a file block (label FBLOK). There are two important
*  pieces of information in the FBLOK - the file name, type and mode
*  of the program to be called, and the default host environment to
*  be used by the called REXX program. The default host environment
*  is contained in the file block extension.  See the FBLOK data
*  declaration below.
*
*
         CMSCALL PLIST=PLISTA,EPLIST=EPLISTA
*
*  Program termination
*
         CMSRET RC=0
*
*  The sub-command entry point.
*  The usual CMSCALL register conditions apply:
*  R0 points to an EPLIST, if one was supplied (REXX always does)
*  R1 points to the PLIST
*  R2 points to the SCBLOK for the sub-command entry point.
*  R12 is the address of the called program
*  R13 points to a user save area that contains call type information.
*  R14 is the return address.
*  R15 is the address of the called program.
*
*  Print a message to show we made it here.
*  If an argument string was supplied, display it and return with a
*  return code of 0, otherwise return with a return code of 1.
*  We assume an EPLIST was supplied (if called from our REXX program
*  REXX will do this), and that the argument string is less than or
*  equal to 256 characters in length.
*
ENV      EQU   *
         DROP  12
         USING *,12          Establish addressability, since
*                            just entered here.
         LR    5,0           R5 -> EPLIST
         APPLMSG APPLID=USR,TEXT='SUBCOM ENV'
         L     3,4(0,5)      R3 -> BEGARGS from EPLIST
         L     4,8(0,5)      R4 -> ENDARGS from EPLIST
         SR    4,3           R4 = length of argument
         BNZ   ARGOK         Is there an argument?
         LA    15,1          Set return code to an error code,
         B     DONE          and return
ARGOK    STC   4,MSGBUF      Store the argument length in the buffer
         MVC   MSGBUF+1(256),0(3)   Move 256 bytes to message buffer
         APPLMSG APPLID=USR,TEXTA=MSGBUF
         LA    15,0          Set return code to 0.
DONE     EQU   *
         BR    14            Return to the caller.
*
* Data declarations
*
         DS    0D
PLISTA   DS    0F
         DC    CL8'EXEC'
         DC    CL8'DIFFENV'
         DC    8X'FF'
*
EPLISTA  DS    0F
         DC    A(PLISTA)
         DC    A(BEGARG)
         DC    A(ENDARG)
         DC    A(FBLOK)
*
COMMAND  DC    C'DIFFENV'
BEGARG   DC    C' cmd This is the argument'
ENDARG   DC    C' '
*
* The file block.
* See the System Product Interpreter Reference, SC23-0374-0,
* page 144 (in Chapter 9, System Interfaces).
*
*
*  This is used to perform any of several functions relating to the
*  execution of a REXX program. The first section contains a file
*  name, type, and mode. It is the name of the REXX program to be run.
*  This can be different than the program name in the PLIST, in which
*  case the file block name is used. Following the file name, type
*  and mode is the file block extension length, in units of fullwords.
*  If it is zero, then no other information is supplied in the file
*  block. If it is greater than 2, then the 2 words following the file
*  block extension length specify the address and length of an in
*  storage program descriptor list for a REXX program to be executed
*  from storage. These may be 0 if the program is not to be executed
*  storage. If the extension length is greater than 4, then words
*  3 and 4 of the file block extension specify a default host
*  environment to be used instead of the program's file type.
*
FBLOK    DS    0F            File block
         DC    CL8'DIFFENV'
         DC    CL8'GORP'
         DC    CL2'* '
         DC    H'4'               FBLOK extension is 4 fullwords
         DC    2F'0'              No in storage program
         DC    CL8'ENV'           Default host environment
*
*  A buffer for a message to be displayed by the APPLMSG macro.
*  Needed because APPLMSG requires the first byte of the message text
*  be the message length.
*
MSGBUF   DC    64F'0'
         END



E. Lansing, MI 48823          Voice:    H: 517-332-2173
                                        W: 517-337-4949



Tue, 19 Mar 1996 22:50:03 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Calling FoxPro program from within Clipper program

2. Calling a python program within a python program

3. rexx program calling cobol program

4. Calling a REXX program from a C program.

5. Assembler code within a COBOL/370 program?

6. Stopping A REXX Program With Another REXX Program

7. sharing external functions between cms rexx programs and xedit rexx programs

8. Call a REXX Exec and have it Address the calling program

9. executing dos program within program

10. Q: Executing programs from within a program

11. - How can I call a windows program from within Squeak

12. C call, in a Fortran subroutine, within a C main program

 

 
Powered by phpBB® Forum Software