Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Regarding Inspect
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Wed Oct 08, 2008 8:29 am    Post subject: Regarding Inspect
Reply with quote

I have a Variable which contains the data like this.

'ABC' '' '12' 'WE' '' 'RY' '' 'REST' 'GR'

I need to find out the occurances of this string"' '' '" (double occurances of single quotes).

Can any one help me out in this.

For the above case the count should be 2 as there are two occurances of single quotes of this tpte ' '' '
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Oct 08, 2008 9:04 am    Post subject:
Reply with quote

Hello,

You need to use the "Code" tag when you post "data" (or code or jcl or. . ).

It appears the count you menton is incorrect - there are 3 sets, not 2.

Please correct your post in a reply that uses the "Code" tag.
Back to top
View user's profile Send private message
Cristopher

New User


Joined: 31 Jul 2008
Posts: 53
Location: NY

PostPosted: Wed Oct 08, 2008 1:26 pm    Post subject: Reply to: Regarding Inspect
Reply with quote

Hi,
I assume that you have to capture
Code:
' '' '
in your input string.
Try to use the following code-
Code:
INSPECT ws-string TALLYING K FOR ALL X'7D407D7D407D'

Hope it helps.

Cris
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Oct 08, 2008 1:30 pm    Post subject:
Reply with quote

Hello,

Still looking for the corrected/coded post. . .

Code:
INSPECT ws-string TALLYING K FOR ALL X'7D7D'
should tally the number of times there are consecutive pairs of single quotes.
Back to top
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Wed Oct 08, 2008 3:12 pm    Post subject:
Reply with quote

Code:
'ABC' '' '12' 'WE' '' 'RY' '' 'REST' 'GR'


Dick I believe, He has to validate double quotes ie
Code:
 "


So If that is the case; he has use 7F in inspect Verb

Code:
INSPECT ws-string TALLYING K FOR ALL X'7F'
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Oct 08, 2008 7:44 pm    Post subject:
Reply with quote

Hello,

Quote:
So If that is the case; he has use 7F in inspect Verb
No, he needs a pair of x'7d's (as i previously posted).
Code:
 "  '
474474
0F00D0
Notice that x'7f' is the hex for a 1-byte double-quote - which has nothing to do with the request.

Code:
INSPECT ws-string TALLYING K FOR ALL X'7F'
There is no reason at all to do this. . .

I suspect you posted something you "think", but did not test. Please re-read the original request and then look at what you suggested. They are not the same. If you post a suggestion/solution, it should be tested and you should verify what you tested and the result you received when you ran the test.
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Wed Oct 08, 2008 11:42 pm    Post subject:
Reply with quote

dick scherrer wrote:
Hello,

You need to use the "Code" tag when you post "data" (or code or jcl or. . ).

It appears the count you menton is incorrect - there are 3 sets, not 2.

Please correct your post in a reply that uses the "Code" tag.


Extremely Sorry for the late reply...

Dick as you said it should be 3 only.

I have to count the occurances of consecutive pair of quotes.

Code:


' '' '



Quote:


I assume that you have to capture Code:
' '' '
in your input string.

Cristopher you are correct.This is my requirement.

Can i go ahead with Cristopher Solution..Please let me know your Views.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Oct 08, 2008 11:55 pm    Post subject:
Reply with quote

Hello,

Quote:
Can i go ahead with Cristopher Solution..Please let me know your Views.
If you use this, it will possibly allow a pair of x'7d' bytes to be missed. Using the "Christopher code" will only find the set of doubles when they bounded by spaces and other quotes.

If you use what i posted, you will find the pairs regardless of "their neighbors".

What should be the result when the data contains:
Code:
'ABC' '' '12' 'WE' '' 'RY' ''  ''  'REST' 'GR' ''
icon_question.gif
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Thu Oct 09, 2008 12:08 am    Post subject:
Reply with quote

dick scherrer wrote:


What should be the result when the data contains:
Code:
'ABC' '' '12' 'WE' '' 'RY' ''  ''  'REST' 'GR' ''
icon_question.gif


Here also i need i should get the count as 3.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Oct 09, 2008 12:18 am    Post subject:
Reply with quote

Hello,

Quote:
Here also i need i should get the count as 3.
How was 3 determined? The data contains 5 sets of doubled single-quotes icon_confused.gif

Neither the Christopher code nor mine will give a result of 3. The Christopher code will give 2 and mine will give 5. How/why would you get 3?
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Thu Oct 09, 2008 12:25 am    Post subject:
Reply with quote

dick scherrer wrote:
Hello,

Quote:
Here also i need i should get the count as 3.
How was 3 determined? The data contains 5 sets of doubled single-quotes icon_confused.gif

Neither the Christopher code nor mine will give a result of 3. The Christopher code will give 2 and mine will give 5. How/why would you get 3?


Sorry Dick It is Parallox Error.I should get 2.

Thanks for the correction.

Dick can you please explain why your code gives 5.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Oct 09, 2008 1:13 am    Post subject:
Reply with quote

Hello,

From earlier:
Quote:
Code:
INSPECT ws-string TALLYING K FOR ALL X'7D7D'

should tally the number of times there are consecutive pairs of single quotes.
On the original data, both the Chrostopher code and the code i posted would return 3.

Quote:
Dick can you please explain why your code gives 5.

Because the sample data was not (IMHO) a good representation, i added to the original as:
Code:
'ABC' '' '12' 'WE' '' 'RY' ''  ''  'REST' 'GR' ''
Note that there now are 5 pairs. My code will "count" all 5. The Christopher code will only count 2. Why should the original count be 2 - there are clearly 3 icon_confused.gif

I believe that before you implement anything, you need to make sure you have a consistent requirement definition that makes sense. What you have described so far is not consistent and i expect would cause long-term problems when executed or maintenance was needed.

If we get to a common understanding of what is really needed, i'll be happy to go back over the topic and edit the replies so that what you really need is what remains in your topic icon_smile.gif
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Thu Oct 09, 2008 10:00 am    Post subject: Reply to: Regarding Inspect
Reply with quote

Thanks Dick.. I will discuss the same with my Lead and let you Know.

Thanks to everyone for your valuable replies.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Oct 09, 2008 10:47 am    Post subject:
Reply with quote

looking at the OP's original post,
it appears
(i assume)
that the 'double single quotes' could be looked at
as double colons in a csv file where the double colon indicates an unfilled field.

Wthout the benefit of code/code tags,
hard to see what really is there,
since we can not tell where spaces are.

will be interesting to see what guidance his lead provides.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Oct 09, 2008 10:52 am    Post subject:
Reply with quote

You're welcome icon_smile.gif

I also need to add that there is nothing wrong with the Christopher code. It is possible that the "wider" search value is what is needed. I did not want to imply that one way was right and the other wrong, just that they enforce different "rules".
Back to top
View user's profile Send private message
Krishna Velamur

New User


Joined: 22 Aug 2008
Posts: 22
Location: Hyderabad

PostPosted: Fri Oct 10, 2008 10:22 am    Post subject:
Reply with quote

Hi all,

I tried the below solution but it didn't work and the count was zero.
Code:
INSPECT STR-1 TALLYING W-CNT FOR ALL ''''''''


But when I moved
Code:
''''''''
to a variable and tried it worked.
i.e.
Code:
MOVE " '''''''' " TO STR-2

INSPECT STR-1 TALLYING W-CNT FOR ALL STR-2.


Corrections are welcome.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Oct 10, 2008 12:06 pm    Post subject:
Reply with quote

Hello,

I am having trouble relating your post to the requirement of this topic icon_confused.gif

Maybe if you explain the string of quotes ( '''''''' ), it will help me understand.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Fri Oct 10, 2008 12:42 pm    Post subject:
Reply with quote

Krishna,

Edited your post with BBCode, in case it didn't reflect what you actually wanted to convey, please PM to me. BTW, I echo Dick.

-Ad
Back to top
View user's profile Send private message
Krishna Velamur

New User


Joined: 22 Aug 2008
Posts: 22
Location: Hyderabad

PostPosted: Fri Oct 10, 2008 2:25 pm    Post subject:
Reply with quote

Hi Dick,
To find out consecutive occurence of ' (single code) I will inspect the string with " '''''''' ". (Here '''' will represent one single code).

But when I harcoded codes in the inspect statement (as given below) it was not working. The count was zero.

INSPECT STR-1 TALLYING W-CNT FOR ALL ''''''''

Instead of harcoding, I moved " '''''''' " into another variable and used it in the inspect statement and it worked (as given belwo).

MOVE " '''''''' " TO STR-2

INSPECT STR-1 TALLYING W-CNT FOR ALL STR-2.

Hope Iam clear. Corrections are welcome.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Oct 10, 2008 8:45 pm    Post subject:
Reply with quote

Hello,

Yes, but where did the requirement to tally a string of single-quotes come from icon_confused.gif

It is not part of the requirement that Sri asked about.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Inspect statement spoorni COBOL Programming 5 Mon Jun 06, 2016 9:53 pm
No new posts Using Inspect in cobol Ajay Dwivedi COBOL Programming 8 Sat Sep 26, 2015 11:33 pm
No new posts EQUIVALENT OF COBOL INSPECT IN REXX pshongal CLIST & REXX 2 Fri Nov 22, 2013 10:44 am
No new posts Find the occurrence of keywords using... suraaj COBOL Programming 15 Fri Aug 30, 2013 8:27 pm
No new posts Inspect using replace dharmaraok COBOL Programming 9 Fri Aug 16, 2013 10:28 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us