Solved

Cobol Q - INSPECT

Posted on 2001-06-03
10
3,465 Views
Last Modified: 2012-06-22
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
Comment
Question by:Paurths
  • 7
  • 2
10 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 50 total points
ID: 6150144
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
 
LVL 12

Author Comment

by:Paurths
ID: 6150161
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
 
LVL 12

Author Comment

by:Paurths
ID: 6150162
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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 12

Author Comment

by:Paurths
ID: 6150163
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6150309
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
 
LVL 54

Expert Comment

by:nico5038
ID: 6150324
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
 
LVL 12

Author Comment

by:Paurths
ID: 6153872
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
 
LVL 12

Author Comment

by:Paurths
ID: 6153877
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
 
LVL 12

Author Comment

by:Paurths
ID: 6153879
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
 
LVL 12

Author Comment

by:Paurths
ID: 6153882
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This is about my first experience with programming Arduino.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question