View previous topic :: View next topic
|
Author |
Message |
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Cristopher
New User
Joined: 31 Jul 2008 Posts: 53 Location: NY
|
|
|
|
Hi,
I assume that you have to capture
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
|
|
Code: |
'ABC' '' '12' 'WE' '' 'RY' '' 'REST' 'GR' |
Dick I believe, He has to validate double quotes ie
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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).
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 |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
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.
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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' '' |
|
|
Back to top |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
dick scherrer wrote: |
What should be the result when the data contains:
Code: |
'ABC' '' '12' 'WE' '' 'RY' '' '' 'REST' 'GR' '' |
|
Here also i need i should get the count as 3. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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
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 |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
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
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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
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 |
|
Back to top |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
Thanks Dick.. I will discuss the same with my Lead and let you Know.
Thanks to everyone for your valuable replies. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
You're welcome
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 |
|
|
Krishna Velamur
New User
Joined: 22 Aug 2008 Posts: 22 Location: Hyderabad
|
|
|
|
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
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
I am having trouble relating your post to the requirement of this topic
Maybe if you explain the string of quotes ( '''''''' ), it will help me understand. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
Krishna Velamur
New User
Joined: 22 Aug 2008 Posts: 22 Location: Hyderabad
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Yes, but where did the requirement to tally a string of single-quotes come from
It is not part of the requirement that Sri asked about. |
|
Back to top |
|
|
Krishna Velamur
New User
Joined: 22 Aug 2008 Posts: 22 Location: Hyderabad
|
|
|
|
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 |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Krishna,
Please use BBCode to preserve accurate spacing. See FAQ. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
what is wrong with definining a variable PIC X(02) value ''''. ? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
This is the requirement right!!!! |
Yup, sure is
The "string" of quotes did not equate to one pair of consecutive single-quotes to my (easily confused) mind
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 |
|
|
Krishna Velamur
New User
Joined: 22 Aug 2008 Posts: 22 Location: Hyderabad
|
|
|
|
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 |
|
|
|