View previous topic :: View next topic
|
Author |
Message |
pkd2k5
New User
Joined: 30 Jul 2005 Posts: 1
|
|
|
|
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 |
|
|
hsourabh
New User
Joined: 24 May 2005 Posts: 12 Location: Z?rich
|
|
|
|
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 |
|
|
pravin madoori
New User
Joined: 29 Jan 2007 Posts: 25 Location: Hyderabad
|
|
|
|
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 |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
|