Solved

Cobol Q - INSPECT

Posted on 2001-06-03
10
3,457 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 12

Author Comment

by:Paurths
Comment Utility
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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 54

Expert Comment

by:nico5038
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now