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
 

 

Function pointer in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
prashant_mq

New User


Joined: 29 Aug 2006
Posts: 24

PostPosted: Sat May 31, 2008 12:07 am    Post subject: Function pointer in cobol
Reply with quote

Hi All,


I need to use a function pointer to populate a variable for an API call to succeed.

In cobol we do not have function pointers but how can I get one.

A sample code would help a lot

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

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat May 31, 2008 12:13 am    Post subject:
Reply with quote

Hello,

Please show what you are trying to do.

Show which api and what info needs to be processes by the api.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sat May 31, 2008 12:29 am    Post subject: Re: Function pointer in cobol
Reply with quote

If your COBOL version/release is less than any version of COBOL2 (the first version/release to offer POINTERS), then a "POINTER" variable is not available. However, you're not out of luck.

Do you want to populate a 4-byte field of some kind with the address of a variable?

Here's an Assembler sub-program which will do this -

Code:

GETADDR  CSECT                                                           
         USING *,R3                INFORM ASSEMBLER                       
         SAVE (14,12)              SAVE REGISTERS                         
         LA    R3,0(,R15)          R3 IS BASE                             
         LM    R7,R8,0(R1)         PARM ADDRESSABILITY                   
         LA    R8,0(,R8)           CLEAR TOP-BIT                         
         ST    R7,0(,R8)           POPULATE PARM-POINTER                 
         SLR   R15,R15             ALL IS WELL                           
         RETURN (14,12),RC=(15)    RESTORE AND RETURN                     
         YREGS                                                       
         END                                                             

You CALL this sub-program, passing the variable as parm-01 and a PIC 9(08) COMP field as parm-02.

Upon return, the PIC 9(08) COMP parm-02 field will contain the address of the parm-01 variable.

You're done!

HTH....

Regards,

Bill
Back to top
View user's profile Send private message
prashant_mq

New User


Joined: 29 Aug 2006
Posts: 24

PostPosted: Sat May 31, 2008 12:56 am    Post subject: Reply to: Function pointer in cobol
Reply with quote

Hi...

The API call has one of the input parameters which expects a function pointer for it to work properly.

Currently I am getting IGYDS1089 -S "FUNCTION POINTER" was invalid.Scanning was resumed at the next area A item.

1.Could you please confirm my understanding that there is no data type as FUNCTION POINTER IN COBOL.
2.If it is not there,how can I convert a normal pointer to a function pointer.A code snippet would be of much use.

Thanks
Back to top
View user's profile Send private message
prashant_mq

New User


Joined: 29 Aug 2006
Posts: 24

PostPosted: Sat May 31, 2008 1:11 am    Post subject: Reply to: Function pointer in cobol
Reply with quote

I am using IBM VS COBOL II release 4.0
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sat May 31, 2008 1:24 am    Post subject: Re: Function pointer in cobol
Reply with quote

Unfortunately, I read your post too fast because FUNCTION-POINTER (note the hyphen) was introduced with OS/390 COBOL version/release 2.1, around 10 years ago.

Providing you're on this minimum version/release which supports this FUNCTION, you need a hyphen between FUNCTION and POINTER and you'll be good to go.

Regards,

Bill
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sat May 31, 2008 1:43 am    Post subject: Reply to: Function pointer in cobol
Reply with quote

OK, I'm slipping in my old age. icon_redface.gif

FUNCTION-POINTER was introduced with Enterprise COBOL 3.1, but that doesn't do you much good.

PROCEDURE-POINTER was introduced with COBOL/370 (the successor to COBOL2), some 15 years ago and are similar to FUNCTION-POINTER.

However, because you're on COBOL2, PROCEDURE-POINTER is not available either.

Are you attempting to load a dynamic module into core and obtain its load-point address?

As far as I know, any version/release prior to COBOL/370 would require a CALL to a user-written Assembler Sub-Program, which issues an MVS LOAD Macro (loads the module into memory) and returns the address of the loaded module to the Caller.

Is this by chance a CICS program is Batch?

Bill
Back to top
View user's profile Send private message
prashant_mq

New User


Joined: 29 Aug 2006
Posts: 24

PostPosted: Sat May 31, 2008 3:07 am    Post subject: Reply to: Function pointer in cobol
Reply with quote

Hi,

Thanks a lot for the help.I just pointed my code to the enterprise cobol and it just seems to pass with RC=0.

Now,,I face a abend U4038.
CEE3191E --An attemptwas made to initialize an AMODE24 application without using run-time option

Any ideas on this abend.

Thanks in advance.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat May 31, 2008 3:58 am    Post subject:
Reply with quote

Hello,

You should talk with your system support people and ask for the proper jcl to assemble and link your module. Once you use the correct link jcl, the xMODE conflict should be resolved.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am


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