Highlighted
Absent Member.
Absent Member.
1261 views

Initialize and Call

Jump to solution

I've set up a very simple Console Application project in Visual Studio running Visual COBOL 2.2. Program1 initializes a group level redefine and then passes it to Program2. In Program2, it appears that the field within the group that was not used in Program1 was not actually initialized. Why would this be?

I expect the second display in Program2 to show PROGRAM2, FIELD-2B is empty. However, it shows the field has the value "ST" unless the second display in Program1 is uncommented.

PROGRAM-ID. PROGRAM1.

DATA DIVISION.

WORKING-STORAGE SECTION.

01 GROUP-1.

02 FIELD-1 PIC X(4).

01 GROUP-2 REDEFINES GROUP-1.

02 FIELD-2A PIC X(2).

02 FIELD-2B PIC X(2).

PROCEDURE DIVISION.

MOVE "TEST" TO GROUP-1.

INITIALIZE GROUP-2.

DISPLAY "PROGRAM1, FIELD-2A: " FIELD-2A.

* Uncomment the following display to see FIELD-2A passed to PROGRAM2 initialized

* DISPLAY "PROGRAM1, FIELD-2A: " FIELD-2B.

CALL "PROGRAM2" USING GROUP-1.

GOBACK.

 

PROGRAM-ID. PROGRAM2.

DATA DIVISION.

WORKING-STORAGE SECTION.

LINKAGE SECTION.

01 GROUP-1.

02 FIELD-1 PIC X(4).

01 GROUP-2 REDEFINES GROUP-1.

02 FIELD-2A PIC X(2).

02 FIELD-2B PIC X(2).

PROCEDURE DIVISION USING GROUP-2.

DISPLAY "PROGRAM2, FIELD-2A: " FIELD-2A.

DISPLAY "PROGRAM2, FIELD-2B: " FIELD-2B.

GOBACK.

  


0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Initialize and Call

Jump to solution

This was a problem that occurred in the 2.2 base release but it has since been fixed in 2.2 update 1.

I just tested it here and it worked correctly.

Are you using 2.2 or 2.2 update1?

Thanks.

View solution in original post

0 Likes
3 Replies
Highlighted
Absent Member.
Absent Member.

RE: Initialize and Call

Jump to solution

Testing this with Visual COBOL 2.0 in Visual Studio 2010 seems to show PROGRAM2, FIELD-2B is empty as expected. That's different from the results above using Visual COBOL 2.2 also in Visual Studio 2010.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Initialize and Call

Jump to solution

This was a problem that occurred in the 2.2 base release but it has since been fixed in 2.2 update 1.

I just tested it here and it worked correctly.

Are you using 2.2 or 2.2 update1?

Thanks.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Initialize and Call

Jump to solution

We have not installed update 1 yet.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.