IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Doubt in using an array in 'if' condition


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
passion_sujesh

New User


Joined: 14 Mar 2008
Posts: 74
Location: India,Chennai

PostPosted: Mon May 31, 2010 3:20 pm
Reply with quote

Hi all,
I have a doubt in using an array in 'if' condition. iam getting compilation error . Can u please help me solve this.
Error message:

variable was not a uniquely defined name. The definition to be used could not be determined from the context. The reference to name was discarded. Expected a reference modification specification but found ")". the if statement was discarded.


In the code i am comparing old value and new value in an field.

Copy book layout:
layout1:
Code:
---------
01 key-field.
     05   field1   pic x(05).
     05   field2   pic x(05).
     05   field3   occurs 2 times.
            10   field4    pic x(05).
            10   field5    pic x(05).

Code:
Code:
ID Division.
.
.
.

Copy layout1 replacing ==key-field== by ==new-field==.
Copy layout1 replacing ==key-field== by ==old-field==.
.
.
if  field4 (1) of new-field not= field4 (1) of old-field
  display ' mismatch'
end-if.
.
.

Note: for normal variables (not array elements) it is fine, i am not getting ay error. I am getting this error only while comparing array elements.


please help me solving this.
Thanks in advance.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon May 31, 2010 3:44 pm
Reply with quote

obviously, your syntax is incorrect.

Syntax diagram
Back to top
View user's profile Send private message
passion_sujesh

New User


Joined: 14 Mar 2008
Posts: 74
Location: India,Chennai

PostPosted: Mon May 31, 2010 4:10 pm
Reply with quote

Hi dbzTHEdinosauer,

Thanks, it has helped me a lot.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon May 31, 2010 4:11 pm
Reply with quote

glad you were able to solve your problem.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
No new posts How to give complex condition in JCL . CLIST & REXX 30
No new posts To find an array of words (sys-symbol... JCL & VSAM 9
No new posts selectively copy based on condition DFSORT/ICETOOL 3
No new posts How to move values from single dimens... COBOL Programming 1
Search our Forums:

Back to Top