Solved

Cobol Q - INSPECT

Posted on 2001-06-03
10
3,469 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android development question 2 81
batch file or script 4 50
CSV file copy field 1 to field 2 2 42
How to delete text box content on subform 1 20
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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 …

726 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