Cobol Q - INSPECT

hi all,

i got a field named 'keyvalues' in a record.
This field holds keywords regarding a newspaper. (eg ; 'programming cobol system analyst') There is also field that holds data on the location of the newspaper in a library.
The meaning of it is that a newspaper (or more) should be easy to find when the user types in keyword.

I assume i have to use INSPECT, but am a bit messing around with the syntax (INSPECT can be used in so many ways, and i need to know which is the correct one to use...)

cheers
Ricky
LVL 12
PaurthsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
nico5038Connect With a Mentor Commented:
My first reaction would be to use the INSPECT TALLY to count the number of occurrences of (one or more?) keyfields. When >0 then you have a HIT ;-)

Nic;o)
0
 
PaurthsAuthor Commented:
Hi Nico,

would it be like this?

01 MyCounter    PIC 99.
01 UserInput    PIC X(10).

ACCEPT UserInput.

MOVE 00 TO MyCounter

INSPECT KeyValues TALLYING MyCounter FOR ALL UserInput.

* Somewhere here i need to retrieve the record Keynbr (of eacht item found) to show on the screen...

cheers
Ricky



0
 
PaurthsAuthor Commented:
more:

i would ofcourse use this INSPECT in the 'Start...read next' example shown in the other thread... that way i can retrieve the record key nbr and the location of that newspaper to show to the user on the screen
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
PaurthsAuthor Commented:
btw, when this is done, i only need to cleen up my screens and the exam is a succes.

Strange, but i have a good feeling about Cobol after using it almost 20 days in a row. (lots of hrs a day... :-)
When i started i really was thinking 'i dont ever want to see this language again'.
How a thought can change 'over night' !
0
 
COBOLdinosaurCommented:
It looks okay if you are supposed to find substings of the key word, not just key words.  For example if the the keywords are' horseback saddle riding

and the user enters horse, back, sad, or ding then you will get a hit.

INSPECT KeyValues TALLYING MyCounter FOR ALL UserInput
                  BEFORE SPACE.

Would still get a hit on back , and on ding if there is a trailing space.

INSPECT KeyValues TALLYING MyCounter FOR ALL UserInput
                  AFTER SPACE.

Would still get a hit on sad and on horse if there is a leading space.

You may want to play around a little, and experiment with some strings where keyword contain other key words.  

The basic loop of reading, initializing the tally, inspecting and saving the location information is fine, but trying to inspect the key word string can give some pretty unexpected results.  That's not just a COBOL thing. Look at some of the strange things the turn up in search engines sometimes.

It's been a while since I used INSPECT, but I think that syntax is correct and I think you can combine before and after claues on a tallying.

HTH

Cd&






0
 
nico5038Commented:
If you do this right, then you should build into your loop a reset (when the user presses a button) to show the next set of hits when the screen is filled and not the whole file has been processed.

The main benefit of learning COBOL will be that the processing of records in a sequential file will become clearer. Soemthing that's also usefull in other languages. In Access the recordprocessing with .movenext and .seek resemble th dynamic file you're coping with here.

If you really want to score, you'd store the first hit of all pages to be shown and build a "page-back" button where the user can scroll back, you using these stored first-row keys to issue a new "naxt" loop.

Clear ?

Nic;o)
0
 
PaurthsAuthor Commented:
well, u guys did it again.

thanx for the assistance.

Cd&, another Q to collect for u : http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=progsoftgen&qid=20129693

and another Q about printing in Cobol: http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=progsoftgen&qid=20129692


cheers
Ricky
0
 
PaurthsAuthor Commented:
well, u guys did it again.

thanx for the assistance.

Cd&, another Q to collect for u : http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=progsoftgen&qid=20129693

and another Q about printing in Cobol: http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=progsoftgen&qid=20129692


cheers
Ricky
0
 
PaurthsAuthor Commented:
well, u guys did it again.

thanx for the assistance.

Cd&, another Q to collect for u : http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=progsoftgen&qid=20129693

and another Q about printing in Cobol: http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=progsoftgen&qid=20129692


cheers
Ricky
0
 
PaurthsAuthor Commented:
well, u guys did it again.

thanx for the assistance.

Cd&, another Q to collect for u : http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=progsoftgen&qid=20129693

and another Q about printing in Cobol: http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=progsoftgen&qid=20129692


cheers
Ricky
0
All Courses

From novice to tech pro — start learning today.