IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Regarding Inspect


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 218
Location: India

PostPosted: Wed Oct 08, 2008 8:29 am
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

Moderator Emeritus


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

PostPosted: Wed Oct 08, 2008 9:04 am
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
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

Moderator Emeritus


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

PostPosted: Wed Oct 08, 2008 1:30 pm
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
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

Moderator Emeritus


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

PostPosted: Wed Oct 08, 2008 7:44 pm
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: 218
Location: India

PostPosted: Wed Oct 08, 2008 11:42 pm
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

Moderator Emeritus


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

PostPosted: Wed Oct 08, 2008 11:55 pm
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: 218
Location: India

PostPosted: Thu Oct 09, 2008 12:08 am
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

Moderator Emeritus


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

PostPosted: Thu Oct 09, 2008 12:18 am
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: 218
Location: India

PostPosted: Thu Oct 09, 2008 12:25 am
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

Moderator Emeritus


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

PostPosted: Thu Oct 09, 2008 1:13 am
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: 218
Location: India

PostPosted: Thu Oct 09, 2008 10:00 am
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
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

Moderator Emeritus


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

PostPosted: Thu Oct 09, 2008 10:52 am
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
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

Moderator Emeritus


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

PostPosted: Fri Oct 10, 2008 12:06 pm
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

Superior Member


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

PostPosted: Fri Oct 10, 2008 12:42 pm
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
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

Moderator Emeritus


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

PostPosted: Fri Oct 10, 2008 8:45 pm
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
Krishna Velamur

New User


Joined: 22 Aug 2008
Posts: 22
Location: Hyderabad

PostPosted: Fri Oct 10, 2008 11:35 pm
Reply with quote

Hi Dick,
The solution that I had provided would find out the number of occurances of two consecutive ' (single code). This is the requirement right!!!! Correct me if Iam wrong.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Fri Oct 10, 2008 11:39 pm
Reply with quote

Krishna,
Please use BBCode to preserve accurate spacing. See FAQ.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Sat Oct 11, 2008 12:48 am
Reply with quote

what is wrong with definining a variable PIC X(02) value ''''. ?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Oct 11, 2008 1:48 am
Reply with quote

Hello,

Quote:
This is the requirement right!!!!
Yup, sure is icon_smile.gif

The "string" of quotes did not equate to one pair of consecutive single-quotes to my (easily confused) mind icon_redface.gif

When i've needed to use one or more quotes as a data value, i've put something in ws (like dbz recommended or with the value QUOTE), or i've used the hex value inline.
Back to top
View user's profile Send private message
Krishna Velamur

New User


Joined: 22 Aug 2008
Posts: 22
Location: Hyderabad

PostPosted: Mon Oct 13, 2008 11:16 am
Reply with quote

Hi Dick,
It was a mistake from my side. Actually I moved the string of quotes into STR-2 which was defined as X(02). Thats the reason why my code was working. As suggested by Dick B, we can move " '' " into a string and use in inspect.


Ex:
Code:
STR-2 PIC X(02) VALUE "''".
INSPECT STR-1 TALLYING W-CNT FOR ALL STR-2


or we can use

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



Hope this helps. Corrections are welcome.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Inspect in Assemebler PL/I & Assembler 10
No new posts Help needed with INSPECT COBOL Programming 3
No new posts Inspect statement COBOL Programming 5
No new posts Using Inspect in cobol COBOL Programming 8
No new posts EQUIVALENT OF COBOL INSPECT IN REXX CLIST & REXX 2
Search our Forums:

Back to Top