IDENTIFICATION DIVISION.
PROGRAM-ID. COMPARE-STRINGS-IN-ARRAY.
DATA DIVISION.
WORKING-STORAGE SECTION.
78 MAX-ITEMS value 3.
77 i pic 9(2).
01 ARRAY.
05 array-items occurs MAX-ITEMS.
10 item pic x(6).
01 RESULTS.
05 filler pic 9(1).
88 equal-strings value 1 when set to false is 0.
PROCEDURE DIVISION.
main.
move "COBOL COBOL COBOL" to ARRAY
perform strings_are_equal
STOP RUN.
strings_are_equal.
display "array:"
set equal-strings to true
perform varying i from 1 by 1 until i > MAX-ITEMS
if item(i) <> spaces
display function trim(item(i)), " " no advancing
if i < MAX-ITEMS and item(i + 1) <> spaces
if item(i + 1) <> item(i)
set equal-strings to false
end-if
end-if
end-if
end-perform
display " "
if equal-strings
display "yes"
else
display "no"
end-if
display " "
.
*> run:
*>
*> array:
*> COBOL COBOL COBOL
*> yes
*>