Highlighted
Absent Member.
Absent Member.
506 views

[archive] How to convert this VB statment to COBOL

[Migrated content. Thread originally posted on 22 July 2004]

I want to write the following VB Statements in AcuCOBOL. What is the correct syntax?

sbrStatus.Panels.Item(2).Text ="My New Value"

or

sbrStatus.Panels(2).Text ="My New Value"


where sbrStatus = object, panels = collection, Item = property of the collection and text is the property of the item.

Thanks.
0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] How to convert this VB statment to COBOL

Originally posted by SRFish
I want to write the following VB Statements in AcuCOBOL. What is the correct syntax?

sbrStatus.Panels.Item(2).Text ="My New Value"


You would think the quick code to make this work would be:
MODIFY @sbrStatus::Panels::Item(2)::Text = "My New Value"
but this does not work because acucobol will not automatically generate a temporary handle for an object in the collection and then dispose of it. So you must do it manually.

I use the approach of getting a handle for the item in the collection and then use that handle to modify it's properties and then dispose of the handle. Remember to declare a variable, with the data type of the collection item, to hold the handle.

Example:


      * Working storage for item data type in the collection
           77 sbrPanel HANDLE OF Panel.
      * Get handle for item in collection.
           INQUIRE sbrStatus @Panels::Item(2)
               IN sbrPanel.
           MODIFY sbrPanel @Text = "My New Value".
      *Dispose of handle to avoid memory leaks
           DESTROY sbrPanel.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] How to convert this VB statment to COBOL

Thanks Dan works well.... Sorry have been away for a while and have just got back to this.

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