WRITE Collection Statement

Writes an element to the list or dictionary.

write-collection-statement

GUID-C13D0E12-EAD9-44C3-855A-F9F4ABBE20FC-low.png
Note: Other formats of this statement are available. See Statements in the COBOL Language Reference.

Example

The following declares and creates a list collection and then writes an element to the list:

       declare stringList as list[string]
       create stringList
       write stringList from "item 0"

The following writes 5 more elements to the list using a perform loop:

       perform varying i as binary-long from 1 by 1 until i > 5
           write stringList from "item " & i
       end-perform

       display "The contents of the list : "           
       invoke displayListContents(stringList)

See also the Collections sample, which is available from Start > All Programs > Micro Focus Enterprise Developer > Samples > Visual COBOL Samples, under COBOL for JVM.