Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

rustym (Programmer) (OP)
30 Jan 02 15:44
I am making a small driver program to call another program. I just realized that I need to use pointers. I have been using the following variables:

01  CALLED-PROGRAM-ID  PIC X(08) VALUE 'ACMPW067'.
01  RET-VAL            PIC 9(02) VALUE 00.
01  IO-AREA            PIC X(3200)  VALUE '02501BE7436561    /101546945ALLALL000021183577'.     

In the driver program, how do I set up some variables as pointers and put some valid info in them prior to sending them off to a called program? I need three pointers. The first one should point to an address which holds a module name like "acmpw022". The second pointer should point to an address which holds a return code... and I want to start it out as 00, which is for successful. The last pointer is for an IO area... the info we want brought back. It will be a mixed string of characters, up to 32000 bytes.

Here's a snippet of the called program:

LINKAGE SECTION.                                          
01  LNK-MODULE-NAME-POINTER      USAGE POINTER.           
01  LNK-COMPLETION-CODE-POINTER  USAGE POINTER.           
01  LNK-IO-AREA-POINTER          USAGE POINTER.           
                                                          
                                                          
PROCEDURE DIVISION NTAPI USING LNK-MODULE-NAME-POINTER    
                               LNK-COMPLETION-CODE-POINTER
                               LNK-IO-AREA-POINTER.       

Any help would be greatly appreciated.
Thanks,
Rusty
k5tm (Programmer)
30 Jan 02 16:21
You need not use POINTER at all in this situation.  COBOL uses call-by-name (USING ... BY REFERENCE in COBOL terms), so modify your called program:


LINKAGE SECTION.                                          
01  LNK-MODULE-NAME              pic x(8)
01  LNK-COMPLETION-CODE          pic 9(02).           
01  LNK-IO-AREA                  x(3200).           
                                                          
                                                          
PROCEDURE DIVISION NTAPI USING LNK-MODULE-NAME    
                               LNK-COMPLETION-CODE
                               LNK-IO-AREA.  

(Some confusion:  in the code sample you use 3200, but your description says 32000.)

Most implementations pass an address/pointer across the calling boundary, but that is invisible to the COBOL programmer.

Tom Morrison

slade (Programmer)
30 Jan 02 17:41
Hi Rusty,

A point of confusion on my part:

You show the called pgm name both in the caller and the called pgm. Why?


Should the call stmt be:
CALL CALLED-PROGRAM-ID USING RET-VAL    
                             IO-AREA               
and the LINKAGE area be:

01  LNK-COMPLETION-CODE     pic 9(02).           
01  LNK-IO-AREA             pic x(3200).


or is the sub-pgm going to call the pgm in
LNK-MODULE-NAME?

Another fine point: you may want to define RET-VAL as
pic xx val '00' in the CALLer. Reason: If the sub-pgm fills RET-VAL with a non-DISPLAY data type, it can cause your CALLer pgm to abend if the field is referenced after the return from the CALL.

HTH, Jack.

                                 
                                                          

            
rustym (Programmer) (OP)
31 Jan 02 9:10
Thanks Tom and Jack, your responses helped a lot!

Tom, after following your suggestion, things seem to work better. I have compiled each project to INT code. (Did I tell you that I'm using Micro Focus Net Express?) However, when I try to step through my trigger program to the called program, I get two message boxes: The first tells me that "The IDY file (of the same name as the CBL file I'm trying to step into) does not contain any info for debugging GNT or OBJ code. You cannot step through this program..." This message has two buttons, one to Run Thru the code, the other to Stop Animating. When I click the Run Thru button, I get the second message box, which says: "Execution of the program EASLBRDG has been interupted. This program is not animatable, but you can view the call stack. The cause of the interrupt was: 114 Attempt to access item beyond bounds of memory."

When I recompile the called program to GNT code and start again to step through from my trigger program, I get the second of the two message boxes mentioned above.

Should I have the trigger program and the called program compiled to the same type code? I don't think you can animate with OBJ code?

Again, thanks for your help,
Rusty
k5tm (Programmer)
31 Jan 02 13:57
Rusty,

I am not familiar enough with the Micro Focus product to be able to help.

I would suggest starting another thread now that you are having a debug problem rather than something that has to do with pointers.  Make sure you mention Net Express in the title, so that appropriate experts will be able to find it.

Best regards,
Tom Morrison

Helpful Member!  BettyScherber (Programmer)
4 Feb 02 17:58
I believe that you will still need to use pointers, because the arguments are defined as pointers.  To create a pointer, code something like this:

   01  LNK-MODULE-NAME-PTR            USAGE POINTER.

then you should be able to fill it in the PROCEDURE DIVISION with this code:

  SET LNK-MODULE-NAME-PTR TO ADDRESS OF LNK-MODULE-NAME-PTR.

Hope this helps,

Betty Scherber
Brainbench MVP for COBOL II
http://www.brainbench.com

rustym (Programmer) (OP)
5 Feb 02 8:47
Thanks, Betty. That was right on the mark.

Did you have any thoughts on the '114 Attempt to access item beyond bounds of memory' warning? Am I doing something wrong which is not allowing me to call the function in the external DLL?

Rusty
k5tm (Programmer)
5 Feb 02 10:26
Well, I'll wade back into this.

Betty's suggestion sets the pointer to point at itself.  An out of bounds reference seems to me to be an expected result.

Rusty, a better approach to solving this problem would be for you to describe what you are trying to accomplish, rather than you so-far-unsuccessful solution.  Using pointers in COBOL is rarely called for in normal programming.  Sometimes there is a better way...

Tom Morrison

winzip (Programmer)
7 Feb 02 14:06
Rusty,

I was at first hesitant to respond to this post because my experience with MicroFocus was over two lifetimes ago.

Anyway, I think I will agree with Tom's initial reaction to your query in that you probably do not need pointers in this case.

And then I will agree with Tom again: give us more info - what are you trying to accomplish - and then perhaps we can be of better help.

Regards.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close