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

how to put quotes in a string in a variable?


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

New User


Joined: 05 Apr 2006
Posts: 3

PostPosted: Wed Apr 05, 2006 8:57 pm
Reply with quote

Hi,

I need to put

Code:
PUT 'DAZDQ.RL3P.SUBCON.WIPAUDT(0)'


including single-quotes in a variable. If i enclose this string with double quotes, it gives me a compile error.

pl help asap
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed Apr 05, 2006 10:27 pm
Reply with quote

Code the variable as:

Code:


01  PUTVAR          pic x(80)  value
    'PUT ''DAZDQ.RL3P.SUBCON.WIPAUDT(0)'''.



(double the apostrophe inside the variable)

Dave
Back to top
View user's profile Send private message
ankur.sanghi

New User


Joined: 05 Apr 2006
Posts: 3

PostPosted: Thu Apr 06, 2006 8:21 am
Reply with quote

I tried doubling the quotes Davidatk, That one doesn't work.
Yesterday, someone suggested that I should use Figurative Constant QUOTE in place of '

Haven't tried that yet. More expert responses plz...
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Apr 06, 2006 5:19 pm
Reply with quote

If you were using COBOL 390, you could just use the double quotes.
But as it does not work with your version of COBOL, you have to code:

Code:

01  PUTVAR.
    03 FILLER    PIC X(4)   VALUE 'PUT '.
    03 FILLER    PIC X      VALUE QUOTE.
    03 FILLER    PIC X(28)  VALUE 'DAZDQ.RL3P.SUBCON.WIPAUDT(0)'.
    03 FILLER    PIC X      VALUE QUOTE.



In case you have a lot of constants like this, there is an easier way: use CBL QUOTE (instead of the default which is CBL APOST)
This option switches the use of quotes and double-quotes. Then you will be able to write:

Code:

01  PUTVAR    PIC X(80) VALUE "PUT 'DAZDQ.RL3P.SUBCON.WIPAUDT(0)'".



Note that in this case you will also have to change all constants:

Code:

MOVE "ankur.sanghi" TO USER-NAME.
DISPLAY "HELLO, " USER-NAME.

Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Apr 07, 2006 7:28 am
Reply with quote

David's suggestion is correct. You didn't show us what you did. You told us what you THINK you did.

Try it, you'll like it.

PS. If the rest of your shop uses single quotes to encase variables, I'd advise you not to use doubles. Unless you want to become famous. icon_evil.gif icon_lol.gif
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Help in extracting data between doubl... DFSORT/ICETOOL 5
Search our Forums:

Back to Top