Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Calling C program from REXX

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: Calling C program from REXX
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.

http://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: 2360
Location: Israel

PostPosted: Wed Sep 12, 2007 11:12 am    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
This topic is locked: you cannot edit posts or make replies. Calling REXX code from ISPF panel sanchita dey TSO/ISPF 4 Mon Jan 02, 2017 5:13 pm
No new posts REXX DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us