READ Collection Statement (JVM COBOL)

Reads an element in the list or in the dictionary from a given key.

read-collection-statement

Syntax of the READ statement for collections
Note: Other formats of this statement are available. See Statements in the COBOL Language Reference.

Where: identifier is the name of the list or dictionary collection type.

Example

The following reads an element from a list collection:

       declare val as string
       read stringList into val key 0

The following example, shows exception handling and catching an exception on reading an invalid key in a dictionary collection:

       display "reading an invalid key message : " 
       read stringDictionary into val key "RUBBISH"
       invalid key
           display "Caught invalid key"
       not invalid key
           display "Shouldn't see this"
       end-read 

See also the Collections sample, which is available from $COBDIR/demo.