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
 

 

Difference between DEF and BASED ADDR

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 270
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Mon Nov 12, 2012 3:37 pm    Post subject: Difference between DEF and BASED ADDR
Reply with quote

Hi,

I'm trying to use a fiexd decimal variable in Char format as below:

Code:

DCL FD73              FIXED DEC(7,3);       
DCL CH73              CHAR(4) DEF FD73;     


And it gives me following error during compilation:
Code:

SEVERE AND ERROR DIAGNOSTIC MESSAGES                                 
                                                                     
IEL0486I E   25      ATTRIBUTES OF 'DEFINED' ITEM 'CH73' CONFLICT WITH THOSE OF BASE.    SIMPLE DEFINING ASSUMED.


But when I try the same with Based Addr function, it works fine:
Code:

DCL FD73              FIXED DEC(7,3);           
DCL CH73              CHAR(4) BASED(ADDR(FD73));


Can anyone help me understand the differnece between the two scenarios described above.
Back to top
View user's profile Send private message

Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1746
Location: Bloomington, IL

PostPosted: Mon Nov 12, 2012 4:27 pm    Post subject:
Reply with quote

It's a compiler thing: the attributes of the defined and base variable differ, so it is possible that data valid for one will not be for the other. The compiler (even one as down-level as yours) protects you from shooting yourself in the foot when using DEFINED.

OTOH, declaring a variable with the attribute BASED is different; it informs the compiler that the declaration is only a description of the variable, and that the address of the storage will be provided on every reference to it (implicitly, as with a reference in the declaration,or explicitly).

In the first case FD73 and CH73 refer to the same storage, period; there is no changing that short of modifying the source and re-compiling it. In the second case, any address, not just that of FD73, may have the description CH73 applied to it; multiple addresses may be used in the same program (of course, those addresses may be of storage not belonging to the enclave, or other invalid scenarios, leading to S0Cx abends...but with great power comes great responsibility).
Back to top
View user's profile Send private message
prino

Active Member


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

PostPosted: Mon Nov 12, 2012 5:04 pm    Post subject: Re: Difference between DEF and BASED ADDR
Reply with quote

mistah kurtz wrote:
I'm trying to use a fiexd decimal variable in Char format as below:

.
.

Can anyone help me understand the differnece between the two scenarios described above.

Maybe you can tell us first why in the world you would do this?
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 270
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Mon Nov 12, 2012 5:12 pm    Post subject:
Reply with quote

@Akatsukami.

Thanks a lot.

@prino
Now that I know, it seems like a wild experiment. :-)
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
No new posts Difference between TWALENG and TWASIZE Arunkumar Chandrasekaran CICS 3 Tue Jan 03, 2017 12:57 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts Sticky: difference between ... DUMMY ... and ... enrico-sorichetti JCL & VSAM 0 Mon Oct 17, 2016 4:31 pm


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