Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 287
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: 1775
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

Senior Member


Joined: 07 Feb 2009
Posts: 1048
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: 287
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 in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 4 Fri Sep 22, 2017 4:56 pm
No new posts BUILD OUTFIL based on condition other... balaji81_k DFSORT/ICETOOL 13 Fri Sep 08, 2017 11:06 pm
No new posts How do you create Eclipse based dialogs jasorn IBM Tools 0 Thu Aug 03, 2017 5:05 pm
No new posts Split file based on comparsion to 2 f... Div Grad DFSORT/ICETOOL 3 Thu Jul 27, 2017 9:16 pm
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us