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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
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    Post subject: How to print a string having sinngle quote(') in it.
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    Post subject:
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    Post subject: can i use '7D'X to check/verify ' in a string
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

Active Member


Joined: 07 Feb 2009
Posts: 989
Location: Oostende, Belgium

PostPosted: Wed Aug 05, 2009 12:24 am    Post subject: Re: can i use '7D'X to check/verify ' in a string
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: 7936
Location: Bellevue, IA

PostPosted: Wed Aug 05, 2009 12:46 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
No new posts Random Password (in string format) ge... ezhavendhan COBOL Programming 10 Mon Aug 29, 2016 3:18 pm
No new posts How to insert a lengthy string havin... vidyaa DB2 7 Thu Aug 25, 2016 5:20 pm
No new posts Which function does the Ampersand (&a... Andi1982 PL/I & Assembler 3 Wed Aug 24, 2016 2:05 pm
No new posts Need a help how to replace a string i... gurunath82 CLIST & REXX 12 Tue Jul 26, 2016 11:43 pm


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