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
|
|
|
|
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
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 |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
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 |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
@Akatsukami.
Thanks a lot.
@prino
Now that I know, it seems like a wild experiment. :-) |
|
Back to top |
|
|
|