Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
Highlighted
MikePolinske
New Member.
1091 views

Intro to OO Programming for COBOL Developers

Jump to solution

Working through the above titled PDF I get a build error with the following line of code:

set an-obj to MyClass::New("Scot")

The error I get is 

Severity

Code

Description

Project

File

Line

Error

COBCH0012 : Operand MyClass is not declared

OOSample

C:\Users\mike\Documents\Visual Studio 2015\OOSample\OOSample\TestMyClass.cbl

7

TestMyClass.cbl looks like:

       program-id. TestMyClass as "OOSample.TestMyClass".

       

       01  an-obj type MyClass.

       procedure division.

     *     set an-obj to new MyClass("Scot")

           set an-obj to  MyClass::New("Scot")

           invoke an-obj::SayHello.

           

       end program TestMyClass.

When I comment out the second "set" statement and uncomment the first, then it works fine.

I am using Visual Cobol Personal Edition 2.3 on Visual Studio 2015 on Windows 10.

Tags (1)
0 Likes
1 Solution

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

RE: Intro to OO Programming for COBOL Developers

Jump to solution

This appears to be a bug in the PDF file.

The second instantiation should contain the keyword type in front of MyClass as MyClass is a class name and not an object itself.

   set an-obj to type MyClass::New("Scot")

I will report this as a bug but I would recommend that you always use the syntax specified in the first form of the statement as this is the newer and simpler version of the syntax.

Thanks.

0 Likes
2 Replies
Micro Focus Expert
Micro Focus Expert

RE: Intro to OO Programming for COBOL Developers

Jump to solution

This appears to be a bug in the PDF file.

The second instantiation should contain the keyword type in front of MyClass as MyClass is a class name and not an object itself.

   set an-obj to type MyClass::New("Scot")

I will report this as a bug but I would recommend that you always use the syntax specified in the first form of the statement as this is the newer and simpler version of the syntax.

Thanks.

0 Likes
MikePolinske
New Member.

RE: Intro to OO Programming for COBOL Developers

Jump to solution

Thank you Chris.  

Being new to OO Cobol I wasn't sure if maybe something had changed between when the PDF came out and Visual Cobol 2.3.

Also, are there any compiler directives to use the ISO standard for OO Cobol since I'm assuming any other OO Cobol tutorials I find will use the ISO version.

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.