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

How to print a string having sinngle quote(') in it.


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pkd2k5

New User


Joined: 30 Jul 2005
Posts: 1

PostPosted: Wed Aug 03, 2005 12:52 am
Reply with quote

If I want to print a string like " sandy's home" in PL/I what will be the syntax? Please write down the code.
Back to top
View user's profile Send private message
hsourabh

New User


Joined: 24 May 2005
Posts: 12
Location: Z?rich

PostPosted: Fri Sep 09, 2005 3:31 pm
Reply with quote

Hi pkd,
This code's surely gonna work, try it out


FUN:PROC OPTIONS(MAIN);
DCL QUOTE CHAR(12) INIT('');
QUOTE = 'SANDY'!!'7D'X!!'S HOME';
PUT SKIP LIST(QUOTE);
END FUN;


Thanks,
Sourabh
Back to top
View user's profile Send private message
pravin madoori

New User


Joined: 29 Jan 2007
Posts: 25
Location: Hyderabad

PostPosted: Tue Aug 04, 2009 10:24 pm
Reply with quote

I tried below code:

select(character1)
when ('&') do; ......end;
when ('"') do;......end;
when(" ' ") do ;....end;;<==== this is not working.. how can i check if my character1 is a single quote[ " ' "]. Can i use 7D'X in when?
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Wed Aug 05, 2009 12:24 am
Reply with quote

pravin madoori wrote:
I tried below code:

select(character1)
when ('&') do; ......end;
when ('"') do;......end;
when(" ' ") do ;....end;;<==== this is not working.. how can i check if my character1 is a single quote[ " ' "]. Can i use 7D'X in when?


A single quote is just that, not what you use, which is a a three-character sequence of a space, a single quote and another space.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed Aug 05, 2009 12:46 am
Reply with quote

The Enterprise PL/I Language Reference (manuals link at the top of the page) states:
Quote:
3.1.3 Using quotation marks

String constants, hexadecimal constants, and the picture-specification are enclosed in either single or double quotation marks.

The following rules apply to quotation marks within a string:

* If the included quotation marks are the same type as those used to enclose the string, you must enter two quotation marks (that is, '' or "") for each occurrence to be included.
so your code needs to be
Code:
when('''') do ;....end;
i.e., a single tic mark to start the string, two single tic marks to denote the single quote mark, and a single tic mark to end the string. I believe (but cannot prove) that this should work as well:
Code:
when("'") do ;....end;
where the spaces you included in your posted string have been removed.
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 -> PL/I & Assembler

 


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 Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts JCL sortcard to print only the records DFSORT/ICETOOL 11
No new posts file manager is doing string conversion IBM Tools 3
Search our Forums:

Back to Top