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

Calling C program from REXX


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

New User


Joined: 10 Aug 2007
Posts: 30
Location: atlanta

PostPosted: Wed Sep 12, 2007 3:01 am
Reply with quote

Hi,

I am trying to call a 'C' program from rexx. I am writing code both for the 'C' program and the rexx program and the example quoted here just describes the problem I am facing but not the complete reasons behind choosing this way. But this is the way I was supposed to do based on architechtural direction.

Here is the code I used to call the 'C' program from rexx.

MyVar = "xxxxxx";
ADDRESS LINKMVS "CHGSTR MyVar";

My requirement is to return a string from the 'C' program. Inorder to do that I am passing a string and try to update it in the 'C' program. Based on the notes I found in the reference manual(see below), any updates to this string (MyVar) should be present in the variable(MyVar) after the control comes back to the rexx program.

In my 'C' program I actual get the reference of the string and I am just chaging the chars present in the string. When I display it in 'C' program it shows as 'yyyyyy' (I displayed the reference of the string before and after changing its value and both are same, which ensures that I didnt do anything wrong in my C program). But when I display it in rexx, it is still 'xxxxxx'.

Why is the value changed in my 'C' program not reflecting back in my rexx program? If there any other way to have a string returned from the 'C' program to my 'rexx' program pls feel free to propose the idea.

Notes from the REXX/MVS reference manual.

As an example, suppose you link to a program called PGMCODES and pass a variable pcode that has the value PC7177. The LINKMVS environment evaluates the value of the variable pcode (PC7177) and builds a parameter list pointing to the value. The halfword length field contains the length of the value, which is 6, followed by the value itself. Suppose the PGMCODES program updates the PC7177 value to the value PC7177ADC3. When the PGMCODES program returns control to the LINKMVS environment, the program must update the length value in the halfword length field to 10 to indicate the actual length of the value it is returning to the exec.

If the value in the length field is greater than 0, the LINKMVS or ATTCHMVS environment updates the variable for that parameter with the value the program returned in the parameter list. If the length field is a positive number, LINKMVS or ATTCHMVS simply updates the variable using the length in the length field.

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IKJ2A304/2.6.9.2?SHELF=&DT=19951106081441

Any help in this regard is highly anticipated.

Thanks
Ramesh.
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Wed Sep 12, 2007 11:12 am
Reply with quote

I'm curios: If you just need to "change a string", then REXX has some powerful built-in functions for string manipulation...

O.
Back to top
View user's profile Send private message
rameshvs
Currently Banned

New User


Joined: 10 Aug 2007
Posts: 30
Location: atlanta

PostPosted: Wed Sep 12, 2007 6:27 pm
Reply with quote

Thanks Ofer,

I have to actually do some data manipulation involving Database and most our application is in C, CPP. I am just checking this by changing a string just to make sure I am able to return back information from a C,CPP program to REXX.

One point I would like to mention here. I am recieving the string as argv[1] in my C program and am changing the string at the memory location of argv[1].

Thanks
Ramesh.V.S.
Back to top
View user's profile Send private message
rohitsir

New User


Joined: 21 Aug 2007
Posts: 32
Location: USA

PostPosted: Wed Sep 12, 2007 7:19 pm
Reply with quote

I have given a thought to your problem. I don't know how to do it but the problem could be that you are passing the variable be value and not by reference.

If you are passing the variable by value then changing its value at memory location in you C program won't help.
Back to top
View user's profile Send private message
rameshvs
Currently Banned

New User


Joined: 10 Aug 2007
Posts: 30
Location: atlanta

PostPosted: Wed Sep 12, 2007 7:25 pm
Reply with quote

Heii .. Rohit,

I have gone through the manual attached on this. Looks like LINKMVS environment is going to substitute those things and pass it by reference. Actually LINKMVS is going to use the registers for passing the parms to the called program.

Please take a look at the manual and let me know if I am missing something in my understanding.

Thanks
Ramesh.
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 Using API Gateway from CICS program CICS 0
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 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