|
View previous topic :: View next topic
|
| Author |
Message |
grasshopper
New User
Joined: 22 Jul 2021 Posts: 12 Location: germany
|
|
|
|
what is the difference between based or defined variables?
How do i define sub-level varibales for this requirement?
Given the following definition:
DCL SET CHAR (100);
The following areas are to be accessed with the help of overlays.
- from position 1 there is a 4-digit personnel number in binary format
- from position 3 on, there is the name (NAME) in the length of 15 bytes, followed by the first name (VNAME) in the same length
- from position 68 there is a 5-digit amount (BETR) with 2 decimal places (--> 5 VK, 2 NK) in unpacked format
- from position 81 there are 10 numbers in unpacked format of 2 bytes length each |
|
| Back to top |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1217 Location: Dublin, Ireland
|
|
|
|
BASED variables are addressed using POINTERS or ADDRESS of, A DEFined variable is defined on an absolute POSition within another variable. I find based variables preferable since a change of an underlying variable will result in recalculation of the address/pointer while something defined an an absolute position does not change its offset.
Several ways of overlaying... though using SET as a variable name is a BAD idea...
| Code: |
DCL 1 OVERLAY BASED ADDR(SET),
3 PERSONNEL_NUM BIN FIXED(15),
3 FULL_NAME,
5 SURNAME CHAR(15).
5 LASTNAME CHAR(15),
3 FILLER1 CHAR(nn),
3 BETR PIC'(999V99),
3 FILLER2 CHAR(nn),
3 NUM_ARRAY(10),
5 PIC('99'); |
You can calculate the size of the fillers. Also, please use code tags where appropriate - as I have done.
Garry. |
|
| Back to top |
|
 |
grasshopper
New User
Joined: 22 Jul 2021 Posts: 12 Location: germany
|
|
|
|
| Garry Carroll wrote: |
BASED variables are addressed using POINTERS or ADDRESS of, A DEFined variable is defined on an absolute POSition within another variable. I find based variables preferable since a change of an underlying variable will result in recalculation of the address/pointer while something defined an an absolute position does not change its offset.
Several ways of overlaying... though using SET as a variable name is a BAD idea...
| Code: |
DCL 1 OVERLAY BASED ADDR(SET),
3 PERSONNEL_NUM BIN FIXED(15),
3 FULL_NAME,
5 SURNAME CHAR(15).
5 LASTNAME CHAR(15),
3 FILLER1 CHAR(nn),
3 BETR PIC'(999V99),
3 FILLER2 CHAR(nn),
3 NUM_ARRAY(10),
5 PIC('99'); |
You can calculate the size of the fillers. Also, please use code tags where appropriate - as I have done.
Garry. |
Thanks Garry. I am learning PL1 and trying to learn it with your solutions and then refering them back to the manual also. This helps me understand the manual better. THANK YOU. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|