View previous topic :: View next topic
|
Author |
Message |
ballalsachin
New User
Joined: 22 Sep 2005 Posts: 15 Location: USA
|
|
|
|
Hi,
I am trying to convert '' to ' ' (Quote + Quote to Quote +Single Space+ Quote ) in a String variable. However I am not being able to write the syntax in Cobol for this.
I tried writing
1. INSPECT STMT REPLACING '''''' BY ''' '''
2. INSPECT STMT REPLACING '''' BY ''' '''
Both the statements failed for Syntax error while compling
Writing with Quotes always troubles me in Cobol. Can someone please help ?
Thanks |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
statement 1) would work if both strings in the replace were of the same length. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Use the hex-notation instead -
Double Quote = X'7F'
Single Quote = X'7D'
Just add comments to the INSPECT so others know what you're trying to accomplish.
Also, INSPECT CONVERTING will generate an in-line TR instruction, whereas, REPLACING will generate a CALL/BALR to a COBOL run-time routine.
Bill |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Reference modification will do what you want. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Your question is formulated in such a way that this could be the correct answer:
Code: |
IF WS-STRING = '''''' THEN
MOVE ''' ''' TO WS-STRING
END-IF |
but this could be the correct answer too:
Code: |
MOVE 0 TO TALLY
INSPECT WS-STRING TALLYING TALLY FOR LEADING ''''''
IF TALLY > 0 THEN
MOVE ''' ''' TO WS-STRING (TALLY:3)
END-IF |
(in that case, you are overriding one character. As GuyC said, it would be better if both strings were the same length.)
Maybe you want to insert a space between 2 consecutive quotes and shift the rest of the string?
That would lead to another correct answer... |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi,
If your "sending " field (i.e., the '') has trailing blanks, this should work:
INSPECT STMT REPLACING '''''b' BY '''b'''
Each b is a space. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
ballalsachin and mmwife, please use BBCode so we can tell the difference between a double quote and 2 consecutive single quotes. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Terry Heinze,
They are single quotes in both posts. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
The point I was trying to make is that it wouldn't need an explanation if you'd used BBCode. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
The point I'm making is I don't HAVE to use BB Code in this case. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
mmwife-Super Moderator wrote: |
The point I'm making is I don't HAVE to use BB Code in this case.
|
people do not have to do anything.
But the simple act of enclosing code with code-tags would be a good example. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
You don't HAVE to do anything you don't WANT to, mmwife, but for us folks who see '"' or "" or '''' have a bit of difficulty telling
Code: |
'"' from "" from '''' |
without using BBCode. Is it that difficult to take the few extra moments to make a post more readable? |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
I've used BB Code before and you guys know that. I didn't use it this time because the OP used single quotes and adequately defined how he used them.
And dbz, it's laughable to be lectured by you on being a good example. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Hey Jack,
I was not lecturing you.
I just stated the obvious, very nicely.
as far as a good example, my posts are usually immaculate, articulate and easy to read due to my usage of bbcode and the preview button (which often leads to late posting) - where I am, IMUO, a very good example.
What you are referring to is my lack of PC/patience - being nice to everybody - which I admit I am a very good example of a bad example.
another reason I responded is - I agree with Terry for the very reasons that he mention in his last post
- you, being a moderator, could have very easily re-edited you post with code tags, but no, you made a COMMAND decision and pompously indicated that there was no need for code tags. I thought you were being a little thinned-skinned and had responded inappropriately, which you last comment has adequately displayed.
- everybody has an excuse for what they have done, but PC is partly about overlooking your needs for adulation and respecting the weakness of others - in this case poor eyesight
With item number 2, by the way, I was lecturing. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
cm' on You old ladies
these flames are just a confirmation of the rightness of Edsger Dijkstra
Quote: |
“The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offense.”
|
see this... thinkexist.com/quotes/edsger_dijkstra/ for other Dikstra concerns
I would even shorten it to something even more categoric like
“Exposure to COBOL ( even for short interval time) cripples the mind"
( as demonstrated by COBOL topics on these forums ) |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hey dbz,
It's not PC, it's CD (Common Decency). |
|
Back to top |
|
|
|