Jürgen Kehr wrote:
Hi,

I'm looking for some sample C/370 code which uses the IRXEXCOM interface to fetch and set REXX variables.
Thanks in advance for any help.


I'm attaching a program from our 2 day course "Introduction
to TSO and REXX APIs" (not sure if a simple text attachement
is allowed, though). For more information about this course
see:

  http://www.trainersfriend.com/TSO_Clist_REXX_Dialog_Mgr/a780descrpt.htm




Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.

303-393-8716
http://www.trainersfriend.com

  z/OS Application development made easier
    * Our classes include
       + How things work
       + Programming examples with realistic applications
       + Starter / skeleton code
       + Complete working programs
       + Useful utilities and subroutines
       + Tips and techniques

==> Check out the Trainer's Friend Store to purchase z/OS  <==
==> application developer toolkits. Sample code in four    <==
==> programming languages, JCL to Assemble or compile,     <==
==> bind and test.                                         <==
==>   http://www.trainersfriend.com/TTFStore/index.html    <==

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html
 /* Copyright (C) 2007 by Steven H. Comstock               Ver2       */
 /*  CRXV                                                             */
 /*                                                                   */
 /*                                                                   */
 /*  C program to work with REXX variables                            */
 /*  using the IRXEXCOM service routine                               */
 /*                                                                   */
 /*  Initial version: copy parm value into WorkArea,                  */
 /*                   copy VAR1 value into WorkArea2,                 */
 /*                   copy WorkArea value into VAR1,                  */
 /*                   copy WorkArea2 value into VAR2                  */
 /*                                                                   */
 /*  Lab assignment:  set VAR3 from a constant value                  */
 /*                   create VAR4 and initialize with constant        */
 /*                                                                   */
 /*                                                                   */

#include <stdio.h>
#include <string.h>

typedef int (*pgm) ();

int  main(int argc, char *argv??(??))
{

 char    eyecatcher[] = "CRXV     Ver2";

 pgm   fetchptr;
 int   rc;
 long  namelen = 4;
 long  worklen;
 union {                                     /* convoluted union     */
  void * shvblock_ptr;                       /* construct in order   */
  struct {                                   /* set the leftmost bit */
          int leftmost_bit :1 ;              /* on in the last arg.  */
         } bit_string;                       /* of our call.         */
       } the_point;

 short i;
 long  parmlen;
 char  constant_1[] = "Test constant value";
 char  irxcon[8] = "IRXEXCOM";
 char  name1 [4] = "VAR1";
 char  name2 [4] = "VAR2";
 char  name3 [4] = "VAR3";
 char  name4 [4] = "VAR4";
 char  workarea [100];
 char  workarea2 [255];
 char  *parm_ptr;
 long  z_ptr = 0;

     /*  - copy VAR1 value into workarea2        */
struct {
        long  ptr1;       /*   - next block on chain          */
        long  ptr2;       /*   - used for fetch next          */
        char  ft;         /*   - Fetch value into buffer      */
        char  return_1;   /*   - function return value        */
        short rsvd1;      /*   - reserved                     */
        long  bf_len;     /*   - length of fetch value buffer */
        void  *name1;     /*   - address of variable name     */
        long  var_len;    /*   - length of variable name      */
        void  *buff;      /*   - address of target buffer     */
        long  new_var1_l; /*   - returns length of value      */
         } fetch_sblock1  =
    {0, 0, 'F', 0x00, 0, 100, &name1, 4, &workarea2, 0};


     /*  - update VAR1 from workarea (parm data) */
struct {
        long  ptr1;        /*   - next block on chain          */
        long  ptr2;        /*   - used for fetch next          */
        char  ft;          /*   - Set value from buffer        */
        char  return_1;    /*   - function return value        */
        short rsvd1;       /*   - reserved                     */
        long  bf_len;      /*   - length of fetch value buffer */
        void  [EMAIL PROTECTED];     /*   - address of variable name     */
        long  var_len;     /*   - length of variable name      */
        void [EMAIL PROTECTED];       /*   - address of target buffer     */
        long  value_len_x; /*   - returns length of value      */
         } update_sblock1  =
    {0, 0, 'S', 0x00, 0, 0, &name1, 4, &workarea, 0};


     /*  - update VAR2 from workarea2            */
struct {
        long  ptr1;       /*   - next block on chain          */
        long  ptr2;       /*   - used for fetch next          */
        char  ft;         /*   - Set value from buffer        */
        char  return_1;   /*   - function return value        */
        short rsvd1;      /*   - reserved                     */
        long  bf_len;     /*   - length of fetch value buffer */
        void  [EMAIL PROTECTED];    /*   - address of variable name     */
        long  var_len;    /*   - length of variable name      */
        void [EMAIL PROTECTED];      /*   - address of target buffer     */
        long  up_len;     /*   - returns length of value      */
         } update_sblock2  =
    {0, 0, 'S', 0x00, 0, 100, &name2, 4, &workarea2, 0};


     /*  - update VAR3 from constant_1           */
struct {
        long  ptr1;       /*   - next block on chain          */
        long  ptr2;       /*   - used for fetch next          */
        char  ft;         /*   - Fetch value into buffer      */
        char  return_1;   /*   - function return value        */
        short rsvd1;      /*   - reserved                     */
        long  bf_len;     /*   - length of fetch value buffer */
        void  [EMAIL PROTECTED];    /*   - address of variable name     */
        long  var_len;    /*   - length of variable name      */
        void [EMAIL PROTECTED];      /*   - address of target buffer     */
        long  val_len;    /*   - returns length of value      */
         } update_sblock3  =
    {0, 0, 'S', 0x00, 0, 100, &name3, 4, &constant_1, 20};


     /*  - create VAR4 from constant_1           */
struct {
        long  ptr1;       /*   - next block on chain          */
        long  ptr2;       /*   - used for fetch next          */
        char  ft;         /*   - Fetch value into buffer      */
        char  return_1;   /*   - function return value        */
        short rsvd1;      /*   - reserved                     */
        long  bf_len;     /*   - length of fetch value buffer */
        void  [EMAIL PROTECTED];    /*   - address of variable name     */
        long  var_len;    /*   - length of variable name      */
        void [EMAIL PROTECTED];      /*   - address of target buffer     */
        long  val_len;    /*   - returns length of value      */
         } create_sblock   =
    {0, 0, 'S', 0x00, 0, 100, &name4, 4, &constant_1, 20};


 /*  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  */
 /*                                                                   */
 /*   Get the parm string into WorkArea                               */
 /*                                                                   */
 /*  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  */

 if (argc >  1)
   {
      for (i=1;i<argc;i++)
       {
       parm_ptr =  strcat(workarea,argv[i]);
       parmlen += strlen(argv[i]);
       parm_ptr =  strcat(workarea, " ");
       parmlen++;
       }
       parmlen--;
   }
 else
   {
      printf("No parms specified\n");
   }

  update_sblock1.value_len_x = parmlen;

  fetchptr = (pgm) fetch("IRXEXCOM");


  /***************************************************************/
  /*                                                             */
  /* access VAR1 and move data into 'WorkArea2'                  */
  /*                                                             */
  /***************************************************************/

  the_point.shvblock_ptr = &fetch_sblock1;
  the_point.bit_string.leftmost_bit = 1;

  rc = (fetchptr) (&irxcon,
                z_ptr,
                z_ptr,
                the_point);


  /***************************************************************/
  /*                                                             */
  /* update VAR1 with data from parm (now in WorkArea)           */
  /*                                                             */
  /***************************************************************/

  the_point.shvblock_ptr = &update_sblock1;
  the_point.bit_string.leftmost_bit = 1;

  rc = (fetchptr) (&irxcon,
                z_ptr,
                z_ptr,
                the_point);

  update_sblock2.up_len = fetch_sblock1.new_var1_l;


  /***************************************************************/
  /*                                                             */
  /* update VAR2 with data from WorkArea2 (previously in var1)   */
  /*                                                             */
  /***************************************************************/

  the_point.shvblock_ptr = &update_sblock2;
  the_point.bit_string.leftmost_bit = 1;

  rc = (fetchptr) (&irxcon,
                z_ptr,
                z_ptr,
                the_point);



  /***************************************************************/
  /*                                                             */
  /* update VAR3 with constant data                              */
  /*                                                             */
  /***************************************************************/

  the_point.shvblock_ptr = &update_sblock3;
  the_point.bit_string.leftmost_bit = 1;

  rc = (fetchptr) (&irxcon,
                z_ptr,
                z_ptr,
                the_point);




  /***************************************************************/
  /*                                                             */
  /* create VAR4, initialize with constant value                 */
  /*                                                             */
  /***************************************************************/

  the_point.shvblock_ptr = &create_sblock;
  the_point.bit_string.leftmost_bit = 1;

  rc = (fetchptr) (&irxcon,
                z_ptr,
                z_ptr,
                the_point);



}


Reply via email to