please tell me how to create dyanmic array in COBOl. using OCCURS clause with DEPENDING ON we can create only static arrays. Is there any possibility to create dynamic arrays in COBOL. Thanks in advance.
Joined: 22 Aug 2005 Posts: 413 Location: Colarado, US
Not in the sense you, as a BASIC-language programmer, would understand 'dynamic array'.
The only way to do this in COBOL is to use a COBOL compiler which supports calls to the current operating system to do your own memory
allocation/reallocation/deallocation and then use POINTER data types to
access that data.
Yes, you could find some programmer to create the code needed, and structure it to resemble BASIC. But any such code will perforce be limited to a specific compiler on a specific target operating system.
Or, instead of using a 'memory' table/array, you could use a random-access file; see ORGANIZATION SEQUENTIAL ACCESS RANDOM RELATIVE KEY IS relative-key-name in your SELECT statements.