IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Difference between DEF and BASED ADDR


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mistah kurtz

Active User


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

PostPosted: Mon Nov 12, 2012 3:37 pm
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: 1787
Location: Bloomington, IL

PostPosted: Mon Nov 12, 2012 4:27 pm
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

Senior Member


Joined: 07 Feb 2009
Posts: 1323
Location: Vilnius, Lithuania

PostPosted: Mon Nov 12, 2012 5:04 pm
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: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Mon Nov 12, 2012 5:12 pm
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 All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Write record twice based on condition... SYNCSORT 7
No new posts Create a specific record/file based o... SYNCSORT 8
No new posts Difference between joblib and steplib JCL & VSAM 2
No new posts Sort based on the record type DFSORT/ICETOOL 1
No new posts Pull data using date difference betwe... DB2 6
Search our Forums:


Back to Top