[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference clt::cobol

Title:VAX/DEC COBOL
Notice:Kit,doc,performance talk info-->DIR/KEY=KIT or DOC or PERF_TALK
Moderator:PACKED::BRAFFITT
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3250
Total number of notes:13077

3235.0. "defining Global variarble in COBOL?" by HGRD01::HOMANSANG (Keith Ho, ISE HK @HGO) Thu Apr 24 1997 05:01

    How can a C module reference a varaible defined in a COBOL module? That
    is, that variable is a sort of global variable which is defined in a
    COBOL module and referenced by other non-COBOL module.
    
    Thanks,
      -- Keith.
T.RTitleUserPersonal
Name
DateLines
3235.1Use CALL or EXTERNALPACKED::BRAFFITTThu Apr 24 1997 07:1413
    One alternative is to pass the variable from COBOL to C via CALL.  The
    default (CALL USING BY REFERENCE) will allow you to modify the variable
    in the C routine and see the results back in the COBOL module after the
    C routine returns.  You can also call from C passing the variable to
    COBOL.
    
    Another alternative is EXTERNAL.  For example:
    
    	01 AEXT PIC 9(5) COMP EXTERNAL.
    
    Then the C program can reference the variable AEXT.  Make sure the
    COBOL program and C program declare AEXT with the same name case if you
    are NOT using OpenVMS.
3235.2Already tried EXTERNAL but doesn't work.HGRD01::HOMANSANGKeith Ho, ISE HK @HGOThu Apr 24 1997 23:2313
    re: .1  Thanks.
    
    I want to use global variable instead of passing parameter.
    
    I already tried EXTERNAL before but I couldn't get what I wanted.
    I used globalref in C and it will result in underfined symbol during
    link time.   Please note that I want the variable defined in COBOL and
    referenced by other non-COBOL module and so I used globalref instead of
    globaldef.
    
    Any more ideas?
    
    -- Keith.
3235.3Use the common reference model rather than globalrefPACKED::BRAFFITTFri Apr 25 1997 10:4440
    Wendy Blatt and Craig Neth both suggested that you need to use the
    common reference model rather than the globalref reference model.
    
***C3235A***
par1:      3
par2:      4
ext1:      5
***END***
    
COB$USER2:[BRAFFITT.WORK]C3235A.COB;1
 
identification division.
program-id. c3235a.
environment division.
data division.
working-storage section.
01 par1 pic s9(5) comp.
01 par2 pic s9(5) comp.
01 ext1 pic s9(5) comp external.
procedure division.
p0.	display "***C3235A***".
	move 1 to par1.
	move 2 to par2.
	move 3 to ext1.
	call "c3235b" using par1 par2.
	display "par1: " par1 with conversion.
	display "par2: " par2 with conversion.
	display "ext1: " ext1 with conversion.
	display "***END***".
	stop run.
 
COB$USER2:[BRAFFITT.WORK]C3235B.C;1
 
int ext1;
c3235b(int *par1, int *par2)
	{
	*par1 = ext1;
	*par2 = 4;
	ext1 = 5;
	}
3235.4HELP CC/EXTERNWIBBIN::NOYCEPulling weeds, pickin' stonesFri Apr 25 1997 15:295
For DEC C, compile with
	CC/EXTERN=COMMON C3235B



3235.5How about VAXC and BASIC?HANDVC::HOMANSANGKeith Ho, ISE HK @HGOMon Apr 28 1997 03:3511
    re: .3, .4
    
    Thanks very much.
    
    How about VAXC and BASIC?   Does anyone know how to do that as there is
    no such /EXTERN (or similar) qualifier?
    
    (I tried EXTERNAL in BASIC data declaration but it doesn't work.)
    
    -- Keith.
    
3235.6.3 works fine for VAX COBOL with VAX CPACKED::BRAFFITTMon Apr 28 1997 07:595
>    How about VAXC and BASIC?   Does anyone know how to do that as there is
>    no such /EXTERN (or similar) qualifier?
    
    .3 worked fine for me with VAX COBOL and VAX C, but  I don't know what
    syntax you need in VAX BASIC to work with the common reference model.