View previous topic :: View next topic
|
Author |
Message |
prashant_mq
New User
Joined: 29 Aug 2006 Posts: 24
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
prashant_mq
New User
Joined: 29 Aug 2006 Posts: 24
|
|
|
|
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 |
|
|
prashant_mq
New User
Joined: 29 Aug 2006 Posts: 24
|
|
|
|
I am using IBM VS COBOL II release 4.0 |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
OK, I'm slipping in my old age.
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 |
|
|
prashant_mq
New User
Joined: 29 Aug 2006 Posts: 24
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|