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

Function pointer in cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Sat May 31, 2008 12:13 am
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Sat May 31, 2008 12:29 am
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
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
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Sat May 31, 2008 1:24 am
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Sat May 31, 2008 1:43 am
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
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

Moderator Emeritus


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

PostPosted: Sat May 31, 2008 3:58 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top