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 

PL/1 help

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


Joined: 06 Dec 2002
Posts: 117
Topics: 44
Location: Chennai,India

PostPosted: Wed Sep 21, 2005 9:15 am    Post subject: PL/1 help Reply with quote

Hi Gurus,
Code:

 PGM: PROC OPTIONS(MAIN);         
 DCL X FIXED BIN(2) BASED(P);     
 DCL Y FIXED BIN(7);               
 DCL Z PIC '999';                 
 Y='1111111'B;                     
 P=ADDR(Y);                       
 Z=X;                             
 PUT LIST('VALUE:',Z);             
 END PGM;                         

My assumption was Z value will be "3" (decimal equivalent is '11'B)
, but Z value was "127"(decimal equivalent is '1111111'B) displayed.
Why does PL/1 does not recognizes definition of X while assigning value of X to Z.

Thanks,
Ravikumar.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Sep 21, 2005 9:35 am    Post subject: Reply with quote

ravikumar_sri2001,

May be you should read this to fully understand Based storage and attribute

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/C2714602/10.5?DT=20020917160741

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
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Wed Sep 21, 2005 10:18 am    Post subject: Reply with quote

ravikumar_sri2001,
You have not defined P. It must be of the type POINTER; or, atleast FIX BIN(31). Since, you have not defined P, default datatype will be taken (FIX BIN(15) or FIX DEC(7,0); I forgot which one).

Perhaps, you should try again, with the correct datatypes.

Also, I do not quite understand, why are you expecting the answer to be 3?
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
ravikumar_sri2001
Beginner


Joined: 06 Dec 2002
Posts: 117
Topics: 44
Location: Chennai,India

PostPosted: Thu Sep 22, 2005 8:30 am    Post subject: Reply with quote

Hi Cogito,

"P" does not need declaration. PL/1 will define it implicitly as POINTER. Variables X and Y are occupying same storage. I have assigned '1111111'B to Y.
When i try assign value of "X" to Z, i thought that it will look definition of X and it will take 2 lowermost bits of X (sine it is defined as BIN(2)) and covert it into ZD and assign it to Z.

Thanks,
Ravikumar.
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Thu Sep 22, 2005 9:00 am    Post subject: Reply with quote

ravikumar_sri2001,
I do not have access to PL/I anymore; but, I am quite sure that implicit datatypes taken by variables can be FIXED BIN or FLOAT and not pointer.
Quote:
When i try assign value of "X" to Z, i thought that it will look definition of X and it will take 2 lowermost bits of X (sine it is defined as BIN(2)) and covert it into ZD and assign it to Z.


No. When you have a FIXED BIN variable as variable (p,q), then for, p<=15, it will stored in half-word binary i.e. 2 bytes.

[--Edited first line to have FLOAT and not FIXED DEC--]
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
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