checking an array

RESET #A1(A14)
RESET #PROGRAM (A7)
REDEFINE #A1(#A2(A7/1:2))
MOVE ‘XXW1027XXV1015’ TO #A1
MOVE ‘XXV1015’ TO #PROGRAM

IF #MODULE-ARRAY() NE #PROGRAM
DISPLAY #MODULE-ARRAY(
)
END

This is a reporting mode program and I want to check for a value in the array. Actually the display stmt should not be executed as the array contains the #program value.
Its actually getting executed because its checking only for the first occurence in the array (xxw1027) which is not equal to #program and hence executing the display stmt.Is there any other way of checking all the occurences in the array. I don’t want to use a “FOR” loop either.
Can someone help me in this?

if not (#module-array(*) = #program)

There are many ways to accomplish what you want.

You could say:

IF NOT (#A2 (*) EQ #PROGRAM)

or,

IF #A2 (*) EQ #PROGRAM
IGNORE
ELSE
DISPLAY…

However, if you simply want a yes/no answer to whether a value exists in a table, and, if this code will be executed a lot, you might want to work with the string #A1 rather than deal with the array #A2.

If you want to read an article about some timing comparisons of EXAMINE’ing a string versus EXAMINE’ing an array versus SCAN, just send me an e-mail (address below in signature)

steve

You must understand how Natural handles arrays in logical conditions.

From the Natural Manual:

Ya I simply want to check if the value exists in the array and this code will be executed many times. Thanks a lot Steve. I’ll send you a mail requesting for the article.Thanks

A point to be noted. Thanks Jerome.
Is the natural manual available online?

The latest product documentation is available online from the Community home page: http://developer.softwareag.com/AdaNat/main/default.htm and then under “Documention” on the left hand side.