View previous topic :: View next topic |
Author |
Message |
gans79 Beginner
Joined: 31 Aug 2005 Posts: 51 Topics: 27
|
Posted: Tue Aug 22, 2006 11:32 pm Post subject: Restrict Linear search |
|
|
hi,
I've a question on Linear seach,i have a table of size 100 but it will not be loaded with data completely, & while performing a search i want to restrict the search such that it searches the table with valid data, & be more efficient,
Thanks
Ganesh |
|
Back to top |
|
 |
mahapatrasoumya Beginner
Joined: 21 Aug 2006 Posts: 8 Topics: 2 Location: Chennai
|
Posted: Wed Aug 23, 2006 1:08 am Post subject: |
|
|
define your table with a depending on clause so that while loading ur table it only loaded as much as your data is. Keep incrementing the value of subscript till ur exhaust all record that have to be loaded.
thanks |
|
Back to top |
|
 |
mahapatrasoumya Beginner
Joined: 21 Aug 2006 Posts: 8 Topics: 2 Location: Chennai
|
Posted: Wed Aug 23, 2006 2:51 am Post subject: |
|
|
Hi gans79,
If you define your table with an indexed by clause even without a depending clause and then do alinear search with the SEARCH keyword your job is done.
Because SEARCH does a linear search and stops as soon as it finds the first occurence of an element.
Thanks,
Soumya |
|
Back to top |
|
 |
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
Posted: Wed Aug 23, 2006 4:46 am Post subject: |
|
|
gans79,
Here in this case if we have a table say with 10 elements and values are already assigned and if we want to find whether the element A1 is found in one of the 10 table entries,we can use this code for serial search.If the element is not found we are displaying as not found and if it found we are displaying as found.
[code:1:80e70f5d7a]
SEARCH TABLE-ENTRY
AT END
MOVE 4 TO RETURN-CODE
DISPLAY 'ELEMENT NOT FOUND'
WHEN TABLE-ENTRY(WS-INDEX) = _________________ Shekar
Grow Technically |
|
Back to top |
|
 |
|
|