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
 

 

Working with Quotes

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Working with Quotes
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: 1278
Location: Belgium

PostPosted: Wed Jan 13, 2010 7:38 pm    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Jan 13, 2010 7:39 pm    Post subject: Reply to: Working with Quotes
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: 7905
Location: Bellevue, IA

PostPosted: Wed Jan 13, 2010 7:52 pm    Post subject:
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: 1218
Location: Israel

PostPosted: Wed Jan 13, 2010 10:01 pm    Post subject: Reply to: Working with Quotes
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    Post subject:
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: 1238
Location: Richfield, MN, USA

PostPosted: Fri Jan 15, 2010 4:16 am    Post subject:
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    Post subject:
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: 1238
Location: Richfield, MN, USA

PostPosted: Fri Jan 15, 2010 6:30 am    Post subject:
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    Post subject:
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    Post subject:
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: 1238
Location: Richfield, MN, USA

PostPosted: Fri Jan 15, 2010 7:02 am    Post subject:
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    Post subject:
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Fri Jan 15, 2010 1:07 pm    Post subject: Reply to: Working with Quotes
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... http://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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SCRNAME not working on my mainframe? mrsidhu12 TSO/ISPF 7 Thu Sep 01, 2016 2:17 pm
No new posts 2 same CLIST pgm but with different n... boyti ko CLIST & REXX 5 Fri Jun 03, 2016 4:55 pm
No new posts REXX Screen not working due to LINKED... sundarkudos CLIST & REXX 1 Mon May 09, 2016 1:44 pm
No new posts Free FILE not working for specific users sankalp-goyal CLIST & REXX 12 Mon Apr 25, 2016 6:33 pm
No new posts To change double quotes into csv read... Robert Sample COBOL Programming 3 Fri Feb 19, 2016 8:13 am


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