Errors using properties

I've been unable to find a way to use the properties in my program without the compiler complaining 'COBCH1304: Method not found in the repository'.

Here's the code:

Int.cbl:

      $SET REPOSITORY "UPDATE ON"
       CLASS-ID. Int INHERITS Base.
       
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Base AS "base".
       
       OBJECT.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
           01  val                     USAGE BINARY-LONG PROPERTY.
       END OBJECT.
       END CLASS Int.

Main.cbl:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. main.
       
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Int
           PROPERTY val
           .
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  foo                         OBJECT REFERENCE Int.
       
       PROCEDURE DIVISION.
           INVOKE Int "NEW" RETURNING foo
           
           *> Errors here.
           MOVE 5 TO val OF foo
           DISPLAY "Value of foo is " val OF foo
           .
       END PROGRAM main.

I would be grateful for any help people could provide.

  • Bump.

    I've now found that adding methods to the OBJECT section allows the property to be used. However, none of the methods can be called and at run time exception 24 will be raised with: 'The class int ... Does not understand: method-name'.

  • I have tested this here and I also find that in order to get this to compile properly a dummy method must be added to the object.
    But I do not experience the run-time error that you are seeing as it runs fine for me.

    I would like to make a suggestion to you.
    The OO syntax that you are using is from the COBOL standard and we refer to that as the old style syntax which is not widely used at all.

    Although Visual COBOL should support this older syntax, a new easier to use syntax is available for managed code projects that make it a simple task to interface directly to managed OO frameworks like .NET and JVM.

    The new syntax does not use separate FACTORY and OBJECT sections and also does not use a REPOSITORY.
    Classes are defined using the TYPE keyword and other constructs like a linkage section have been made optional.

    Please see the new getting started OO programming guide for Visual COBOL here:

    If you do wish to use the COBOL standard OO syntax and you continue to have problems then you should submit a support incident with customer care so that we can try to reproduce the problems using your materials.

    Your example using new style syntax:

    Int class:

     

           class-id managedclass.Int.
           working-storage section.
           01  val        binary-long  PROPERTY.
           end class.
    


    main program:

           program-id. Program1 as "managedclass.Program1".
           data division.
           working-storage section.
           01 foo type Int.
           procedure division.
    
               set foo to new Int
               set foo::val to 5
               display foo::val
               goback.
               
           end program Program1.
    


    You could even define the data item drectly in the procedure division using the declare statement:

           program-id. Program1 as "managedclass.Program1".
           procedure division.
    
               declare foo as type Int = new Int
               set foo::val to 5
               display foo::val
               goback.
               
           end program Program1.
    
  • Thanks for the reply, Chris.

    If you do wish to use the COBOL standard OO syntax and you continue to have problems then you should submit a support incident with customer care so that we can try to reproduce the problems using your materials.

    I would like to do that, but I am unable to as I'm using the Visual Studio 2013 Trial and so have no serial number to register to SupportLine with.