Highlighted
Absent Member.
Absent Member.
1123 views

Properties in Visual COBOL

Jump to solution

[Migrated content. Thread originally posted on 12 December 2011]

Hello,

I want to implement a property, like this one:
        public SortOrder Order
        {
            set
            {
                OrderOfSort = value;
            }
            get
            {
                return OrderOfSort;
            }
        }

Then, I need to reference it in this manner:
        private SortOrder OrderOfSort;

            OrderOfSort = SortOrder.None;

I am not sure if it will work like expected:
       01 _orderOfSort      binary-long.

       method-id set property #orderOfSort.
       procedure division using by value val as binary-long.
           set _orderOfSort to val.
       end method.
     
       method-id get property #orderOfSort.
       procedure division returning ret as binary-long.
           set ret to _orderOfSort.
       end method.

I will appreciate some help, thank you.
0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.
Absent Member.

RE: Properties in Visual COBOL

Jump to solution
The code above should work.

For properties where you just want to expose an underlying member, you can also just use:

01 _orderOfSort  binary-long property as "orderOfSort".

The compiler automatically generates the property getter and setter. This works for traditional COBOL data types and even groups.
You also only need the # to distinguish from COBOL reserved words.
Look out for some even neater property syntax coming in the next release.

View solution in original post

0 Likes
3 Replies
Highlighted
Absent Member.
Absent Member.

RE: Properties in Visual COBOL

Jump to solution
Perhaps doing anything like this:
       class-id MngVirtualListView.SortOrder.
       
       working-storage section.
       01 _orderOfSort      binary-long.

       method-id set property #orderOfSort.
       procedure division using by value val as binary-long.
           set _orderOfSort to val.
       end method.
     
       method-id get property #orderOfSort.
       procedure division returning ret as binary-long.
           set ret to _orderOfSort.
       end method.

       end class.

Then having defined the variable as follows:
       01 orderOfSort       type SortOrder.

I am on it.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Properties in Visual COBOL

Jump to solution
The code above should work.

For properties where you just want to expose an underlying member, you can also just use:

01 _orderOfSort  binary-long property as "orderOfSort".

The compiler automatically generates the property getter and setter. This works for traditional COBOL data types and even groups.
You also only need the # to distinguish from COBOL reserved words.
Look out for some even neater property syntax coming in the next release.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Properties in Visual COBOL

Jump to solution
You don't say!

Do you mean that all will be easier in a near future? And what about my headache?

Funny. Thanks.
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.