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

using based or defined variables


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

New User


Joined: 22 Jul 2021
Posts: 12
Location: germany

PostPosted: Thu Jul 22, 2021 3:21 pm
Reply with quote

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
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Thu Jul 22, 2021 4:26 pm
Reply with quote

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
View user's profile Send private message
grasshopper

New User


Joined: 22 Jul 2021
Posts: 12
Location: germany

PostPosted: Sun Jul 25, 2021 9:12 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts To search DB2 table based on Conditio... DB2 1
This topic is locked: you cannot edit posts or make replies. Merge 2 input files based on the reco... JCL & VSAM 2
No new posts Split large FB file based on Key coun... DFSORT/ICETOOL 4
No new posts Mass JCL release via IDZ tool(eclipse... CA Products 1
No new posts Merge 2 lines based on Space from a S... DFSORT/ICETOOL 5
Search our Forums:

Back to Top