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

Position of index when sequential search in not


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

New User


Joined: 29 Sep 2008
Posts: 6
Location: United Kingdom

PostPosted: Tue Dec 29, 2009 11:49 am
Reply with quote

Hi,
I have a query related to sequential search in COBOL.
What would be the position on index when a sequential search is not successful.
Is it the last position ?
n+1 where n is the last position where data in stored in a table
or n.
Ex - A table with OCCURS 10 INDEXED BY I.
Suppose there is data in 5 positions.
If search is not successful the position of index is 10,6,5. I read somewhere that it is unpredictable.
Please help.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Dec 29, 2009 4:31 pm
Reply with quote

The COBOL Language Reference (manuals link at the top of the page), section 6.2.32.1 on sequential SEARCH, is quite clear:
Quote:
If the end of the table is reached (that is, the value of the incremented index is greater than the highest possible occurrence number) without the WHEN condition being satisfied, the search is terminated.
In other words, the value will be 11 for your example.

Please note that the actual number of elements you've loaded into the table has no bearing upon the SEARCH verb. Only the defined number of elements (10 in your example) matters -- the fact that you've loaded only 5 elements means that you're comparing unknown values for the last 5 search tests (possibly LOW-VALUES, possibly something else).

If a BINARY search fails, the index value will be unpredictable. However, if a SEQUENTIAL search fails the index value is known.
Back to top
View user's profile Send private message
peyush

New User


Joined: 29 Sep 2008
Posts: 6
Location: United Kingdom

PostPosted: Tue Dec 29, 2009 5:41 pm
Reply with quote

Thanks for the response.
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Search two or more word with FILEAID Compuware & Other Tools 15
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts first column truncated in search result IBM Tools 13
No new posts Cobol file using index COBOL Programming 2
Search our Forums:

Back to Top