[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3495
  • Last Modified:

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
0
Paurths
Asked:
Paurths
  • 7
  • 2
1 Solution
 
nico5038Commented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 7
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now