Hi,
Is it possible to declare a variable in a COBOL program that is accessible in another non-cobol program?
Another question, how can I access an EXTERNAL VARIABLE declared to a C Program from COBOL?
Thanks,
Robert Sample wrote:The z/OS Language Environment bookshelf has a book titled Writing Interlanguage Communication (ILC) Applications, and this book has a chapter specifically on C and COBOL communications. If you have not yet read this book and chapter, I recommend you start there.
If you read the manual I referenced, you would find that the answer to your questions is contained in (and I highlighted the key point)Is it possible to declare a variable in a COBOL program that is accessible in another non-cobol program?
Another question, how can I access an EXTERNAL VARIABLE declared to a C Program from COBOL?
So you pretty much need to pass variables between C and COBOL if you want to access the values -- using an EXTERNAL VARIABLE will not allow the C and COBOL programs to interact with the same data.4.4.3 Name Scope of External Data In programming languages, the name scope is defined as the portion of an application within which a particular declaration applies or is known. The name scope of external data differs between C and COBOL. The scope of external data under C is the load module; under COBOL, it is the enclave (or run unit). Figure 7 in topic 4.4.3.2 and Figure 8 in topic 4.4.3.3 illustrate these differences. Because the name scope for C and COBOL is different, external variables do not map between C and COBOL; external variables with the same name are considered separate between C and COBOL. If your application relies on the separation of external data, do not give the data the same name in both languages within a single application. If you give the data in each load module a different name, you can change the language mix in the application later, and your application still behaves as you expect it to.
4.4.3.1 DLL Considerations
4.4.3.2 Name Scope of External Data in a C Application
4.4.3.3 Name Scope of External Data in a COBOL Run Unit