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

Working with Quotes


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

New User


Joined: 22 Sep 2005
Posts: 15
Location: USA

PostPosted: Wed Jan 13, 2010 7:28 pm
Reply with quote

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
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Jan 13, 2010 7:38 pm
Reply with quote

statement 1) would work if both strings in the replace were of the same length.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Jan 13, 2010 7:39 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Wed Jan 13, 2010 7:52 pm
Reply with quote

Reference modification will do what you want.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Wed Jan 13, 2010 10:01 pm
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Jan 14, 2010 5:32 am
Reply with quote

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
View user's profile Send private message
Terry Heinze

JCL Moderator


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

PostPosted: Fri Jan 15, 2010 4:16 am
Reply with quote

ballalsachin and mmwife, please use BBCode so we can tell the difference between a double quote and 2 consecutive single quotes.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Jan 15, 2010 6:28 am
Reply with quote

Terry Heinze,

They are single quotes in both posts.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


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

PostPosted: Fri Jan 15, 2010 6:30 am
Reply with quote

The point I was trying to make is that it wouldn't need an explanation if you'd used BBCode.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Jan 15, 2010 6:35 am
Reply with quote

The point I'm making is I don't HAVE to use BB Code in this case.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Jan 15, 2010 7:00 am
Reply with quote

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
View user's profile Send private message
Terry Heinze

JCL Moderator


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

PostPosted: Fri Jan 15, 2010 7:02 am
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Jan 15, 2010 7:15 am
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Jan 15, 2010 8:34 am
Reply with quote

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
  1. I agree with Terry for the very reasons that he mention in his last post
  2. 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.
  3. 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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Fri Jan 15, 2010 1:07 pm
Reply with quote

cm' on You old ladies icon_biggrin.gif
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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Jan 15, 2010 5:10 pm
Reply with quote

Hey dbz,

It's not PC, it's CD (Common Decency).
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 PD not working for unsigned packed JO... DFSORT/ICETOOL 5
No new posts Def PD not working for unsigned packe... JCL & VSAM 3
No new posts Help in extracting data between doubl... DFSORT/ICETOOL 5
No new posts ICETOOL with JOINKEY for Big record l... DFSORT/ICETOOL 12
No new posts JCL JOB Cancel/Purge Not Working JCL & VSAM 6
Search our Forums:

Back to Top