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

Difference between Based and define in PL1.


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

New User


Joined: 21 Sep 2007
Posts: 35
Location: kolkata

PostPosted: Wed Jun 25, 2008 12:43 pm
Reply with quote

Difference between Based and define in PL1.
Back to top
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Wed Jun 25, 2008 1:01 pm
Reply with quote

You can use the DEFINED attribute to overlay variable storage,
but DEFINED overlay the storage permanently.

When based variables are overlaid with a locator reference, the association can be changed at any time in the program by assigning a new value to the locator variable.

Thanks,
Sri Hari G.
Back to top
View user's profile Send private message
saubhik

New User


Joined: 21 Sep 2007
Posts: 35
Location: kolkata

PostPosted: Wed Jun 25, 2008 2:24 pm
Reply with quote

It would be great if you can give some example.
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


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

PostPosted: Wed Jun 25, 2008 2:52 pm
Reply with quote

Here's a couple of samples.

The first code snippet shows use of DEFINED where the record-area is a variable within the program. RECORD_AREA1 and the DEFINED variable are in a fixed location.

Code:
   DCL    RECORD_AREA1         CHAR(80) INIT(' ');
   DCL R1_DEFINED_BYTE_10    CHAR(10) DEF RECORD_AREA1;

    READ FILE (FILE1) INTO(RECORD_AREA1);



whereas the second snippet shows overlaying (redefining) on a relocatable . The READ SET statement relocates the structure to the record in the I/O buffer. The BASED(ADDR(FIELD1)) is also relocated. This cannot be done with DEFINED.

Code:
 DCL    1  RECORD_AREA2    BASED(PTR2),
          3   FIELD1           CHAR(10),
          3   FIELD2           CHAR(70);

  DCL  R2_OVERLAY   CHAR(10)  BASED(ADDR(FIELD1));

    READ FILE(FILE2) SET(PTR2);


Regards,
Garry.
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 DTL - how to define key with stacked ... TSO/ISPF 3
No new posts Timestamp difference and its average ... DB2 11
No new posts Difference when accessing dataset in ... JCL & VSAM 7
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
Search our Forums:

Back to Top