Skip to main content

I currently have the following array declared in my Windows Form

class-id TPS000.TPS0010DForm is partial

                inherits type System.Windows.Forms.Form.

       working-storage section.

       01 multi-line string property occurs 12.

 

The index for this array starts as (0) as follows:

     (0) = 1st Element

      (1) = 2nd Element

      (2) = 3rd Element

Etc………

Is there any way of forcing the index to start at 1 so that the elements are stored as follows:

     (1) = 1st Element

     (2) = 2nd Element

     (3)= 3rd Element

Etc…

Initializing the first index to 1 will make my program easier to code and to debug later on.

I currently have the following array declared in my Windows Form

class-id TPS000.TPS0010DForm is partial

                inherits type System.Windows.Forms.Form.

       working-storage section.

       01 multi-line string property occurs 12.

 

The index for this array starts as (0) as follows:

     (0) = 1st Element

      (1) = 2nd Element

      (2) = 3rd Element

Etc………

Is there any way of forcing the index to start at 1 so that the elements are stored as follows:

     (1) = 1st Element

     (2) = 2nd Element

     (3)= 3rd Element

Etc…

Initializing the first index to 1 will make my program easier to code and to debug later on.

Arrays are indexed as zero based in .NET by default while COBOL tables are indexed as 1 based.

In managed COBOL we support both depending on whether you reference the item using square brackets [] (0 based), or parenthesis () (1 based)

Example: 

01 mystring string occurs 10. 01 mysub pic 9(2) value 0. procedure division. perform varying mysub from 0 by 1 until mysub = 10 set mystring[mysub] to mysub end-perform perform varying mysub from 1 by 1 until mysub > 10 set mystring(mysub) to mysub end-perform

 


Arrays are indexed as zero based in .NET by default while COBOL tables are indexed as 1 based.

In managed COBOL we support both depending on whether you reference the item using square brackets [] (0 based), or parenthesis () (1 based)

Example: 

01 mystring string occurs 10. 01 mysub pic 9(2) value 0. procedure division. perform varying mysub from 0 by 1 until mysub = 10 set mystring[mysub] to mysub end-perform perform varying mysub from 1 by 1 until mysub > 10 set mystring(mysub) to mysub end-perform

 

Okay, thank you!


I currently have the following array declared in my Windows Form

class-id TPS000.TPS0010DForm is partial

                inherits type System.Windows.Forms.Form.

       working-storage section.

       01 multi-line string property occurs 12.

 

The index for this array starts as (0) as follows:

     (0) = 1st Element

      (1) = 2nd Element

      (2) = 3rd Element

Etc………

Is there any way of forcing the index to start at 1 so that the elements are stored as follows:

     (1) = 1st Element

     (2) = 2nd Element

     (3)= 3rd Element

Etc…

Initializing the first index to 1 will make my program easier to code and to debug later on.

Hello,

See if this will help:

 

https://www.microfocus.com/documentation/visual-cobol/vc50/VS2019/GUID-F9751434-1614-4271-A1CD-2078CEC56D5E.html

 


Thanks for the resource!