View previous topic :: View next topic
|
Author |
Message |
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2598 Location: Silicon Valley
|
|
|
|
One of the fields in assembler is declared DS PL3
I want to refer to it from a PLI program. I have to create a PLI structure similar to the assembler dsect. If I declare the field as FIXED BIN(24), it uses four bytes, causing an incorrect offset for other fields.
If I declare it as CHAR(3), it preserves the correct offsets, but how to refer to the numeric data?
I tried something like this:
Code: |
dcl 1 struct1,
2 char1 char(3),
3 fix1 fixed bin(24); |
but the compiler says 'The attribute CHARACTER conflicts with previous attributes and is ignored'.
I also tried:
Code: |
dcl fix2 fixed bin(31);
fix2 = BINARY(char1); |
but it gets ONCODE=612 conversion error occurred when converting a character string to an arithmetic value. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2598 Location: Silicon Valley
|
|
|
|
UNION is the key. I wound up doing this:
Code: |
dcl 1 work1 UNION,
2 txt,
3 txt1 char(1),
3 txt3 char(3),
2 fix1 fixed bin(31);
txt1 = '00'x;
txt3 = asm3;
/* then referring to fix1 */
|
|
|
Back to top |
|
|
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
I'm not so good with PL/I data types, but wouldn't an Assembler PL3 be
Code: |
dcl pl3 fixed decimal(5); |
|
|
Back to top |
|
|
Bernie Rataj
New User
Joined: 02 Jun 2018 Posts: 2 Location: Canada
|
|
|
|
PL3 is packed decimal, length 3 (bytes).
That would correspond to fixed decimal(5), as a nibble of the 3 bytes is for the sign, and the remaining 5 nibbles for digits. |
|
Back to top |
|
|
|