Skip to main content

Hi all,

 

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

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

 

Thanks

Hi all,

 

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

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

 

Thanks

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.

Hi all,

 

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

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

 

Thanks

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

Hi all,

 

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

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

 

Thanks

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.