Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
linear search in array

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL
Author Message
lavanya

New User


Joined: 08 Jul 2005
Posts: 8

PostPosted: Tue Aug 02, 2005 10:16 am    Post subject: linear search in array
Reply with quote

hi,

can we search for an item in the file which is an a table-array format using search syntax.when i tried its always showing "NOT FOUND'.

the file structure,

FD DAT-FILE.
01 DAT-REC.
03 DAT-TABLE OCCURS 2 TIMES INDEXED BY I.
05 NUM PIC 9(3).
05 MARK1 PIC 9(3).
05 MARK2 PIC 9(3).
05 FILLER PIC X(71).

the search syntax

SEARCH DAT-TABLE AT END DISPLAY 'NOT FOUND'
WHEN N IS EQUAL TO NUM(I)
DISPLAY 'MARK1 ',MARK1(I).


clarify my doubt,

thanks,
lavanya
Back to top
View user's profile Send private message
References
shivashunmugam Muthu

Active User


Joined: 22 Jul 2005
Posts: 114
Location: Chennai

PostPosted: Tue Aug 02, 2005 11:22 am    Post subject: Re: linear search in array
Reply with quote

Hi Lavanya,

You have to set the value for your index. Say start from 1. Hav u done that?
Back to top
View user's profile Send private message
shivashunmugam Muthu

Active User


Joined: 22 Jul 2005
Posts: 114
Location: Chennai

PostPosted: Tue Aug 02, 2005 11:27 am    Post subject: Re: linear search in array
Reply with quote

If your table sorted one in the particular key order(Index Key), u dont need to SET the index. You can do SEARCH ALL option. Its called Binary search. In the prev case, what I told is serial search where SETting the index is the must & do only 'SEARCH' nt search all
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 Hours
Page 1 of 1