
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate 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.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Okay, thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hello,
See if this will help:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content