MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Magic PL1 Version 2.3 / 3.4

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 315
Topics: 49
Location: Germany

PostPosted: Fri Oct 06, 2006 7:23 am    Post subject: Magic PL1 Version 2.3 / 3.4 Reply with quote

Hi all,

coding

Code:

DCL X CHAR(8) ;,
X = 'TESTLINE' ;,
SUBSTR(X,2) = SUBSTR(X,1);,
PUT SKIP EDIT(X)(A);,



results using IBM(R) Enterprise PL/I for z/OS V3.R5.M0 (Built:20060425) in TTTTTTTT,

but using IBM OS PL/I OPTIMIZING COMPILER VER 2 REL 3 MOD 0 the statements results in TTESTLIN.


Any comments ?

regards,
bauer
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Fri Oct 06, 2006 8:09 am    Post subject: Reply with quote

bauer,

I guess the results are due to the fact that you did not mention the length on the SUBSTR function.

Try running your code with this statement

Code:

SUBSTR(X,2,1) = SUBSTR(X,1,1);,


Also if you look at the SUBSTR syntax, look at the section that mentions about the variable Z.

Code:

SUBSTR returns a substring, specified by y and z, of x.                   
                                                                           
+------------------------------------------------------------------------+
|                                                                        |
| >>--SUBSTR(x,y--------)--------------------------------------------->< |
|                +-,z-+                                                  |
|                                                                        |
+------------------------------------------------------------------------+
                                                                           
x       String expression. It specifies the string from which the         
        substring is extracted. If x is not a string, it is converted to   
        character.                                                         
                                                                           
y       Expression that is converted to FIXED BINARY(31,0). y specifies   
        the starting position of the substring in x.                       
                                                                           
z       Expression that is converted to FIXED BINARY(31,0). z specifies   
        the length of the substring in x. If z is zero, a null string is   
        returned. If z is omitted, the substring returned is position y in
        x to the end of x.                                                 
                                                                           
The STRINGRANGE condition is raised if z is negative or if the values of y
and z are such that the substring does not lie entirely within the current
length of x. It is not raised when y = LENGTH(x)+1 and z = 0. For an       
example of the SUBSTR built-in function, see "SEARCH" in item SEARCH.     


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 315
Topics: 49
Location: Germany

PostPosted: Fri Oct 06, 2006 9:04 am    Post subject: Reply with quote

kolusu,


well "i guess" is the correct wording. If the length is omitted, the whole string is taken.

If youf code

Code:


DCL X CHAR(8) ;,
X = 'TESTLINE' ;,
SUBSTR(X,3) = SUBSTR(X,1);,
PUT SKIP EDIT(X)(A);,



the result is TETETETE.

What i want is "don't change bytes 1 and 2, set from byte 3 up to the end the old content of x", expected result TETESTLI.

It works with Pl1 2.3 not with the new version 3.5.

The old version works like

(pseudocode)

move x to temp
x = substr(x,1,2) || temp


the new version works like

(pseudocode)

do i = 3 to length(x)
x(i) = x(i - 2)
enddo


The question is not, works Pl1 2.3 correct or Pl1 3.5, the critical situation is, that one pieces of code works different depending on the compiler version.


regards,
bauer
Back to top
View user's profile Send private message
anbesivam
Beginner


Joined: 09 Aug 2006
Posts: 66
Topics: 14

PostPosted: Tue Oct 10, 2006 2:07 am    Post subject: Reply with quote

Hi Bauer,

It's depends up on your compiler options settings.

For more information you can check your compiler listing DFT(Nooverlap) option.

Code:
OVERLAP | NOOVERLAP
If you specify OVERLAP, the compiler presumes the source and target in an
assignment can overlap and generates, as needed, extra code in order to
ensure that the result of the assignment is okay.
NOOVERLAP will produce code that performs better; however, if you use
NOOVERLAP, you must insure that the source and target never overlap.
NOOVERLAP is the default.
Back to top
View user's profile Send private message
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 315
Topics: 49
Location: Germany

PostPosted: Tue Oct 10, 2006 4:02 am    Post subject: Reply with quote

anbesivam,

perfect answer. Yes, I saw it in the Pl1 compiler manual.

Thank you.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group