Highlighted
Trusted Contributor.
Trusted Contributor.
728 views

Dictionary data structure

Hi all,

 

Is there a data structure similar to Python's dictionary?

In other words, an array like: my_dict('name') = 'Jack'

 

Thanks

0 Likes
3 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Dictionary data structure

I'm not sure I understand your question. You can have arrays in COBOL. Data Dictionary from the Acu point of view refer to XFDs, which describe the data within a COBOL FD, and you can have arrays in an FD. These arrays are ordered numerically (ie month-name(01) would be January). You can make an array in XML by using attributes which might match your python example.
0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

RE: Dictionary data structure

thanks for your answer, I am talking about structures in memory not in disk. Propably XML can do the job.
0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Dictionary data structure

You are asking about associative arrays or hash tables. COBOL does not have such a construct in memory, but indexed files could be considered such a construct, but to keep that in memory you would have to allocate a ram disk.

If it's important enough you could use M$ALLOC and build some functions to build a tree structure in memory. You might even find someone who's done that before and posted it on this forum.

If the data is pre-sorted, you could use a simple array, and if the data is sorted, use the binary search "SEARCH ALL" to simulate the hash access. But I suspect it's a dynamic array.
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.