View previous topic :: View next topic
|
Author |
Message |
saubhik
New User
Joined: 21 Sep 2007 Posts: 35 Location: kolkata
|
|
|
|
Difference between Based and define in PL1. |
|
Back to top |
|
|
Srihari Gonugunta
Active User
Joined: 14 Sep 2007 Posts: 295 Location: Singapore
|
|
|
|
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 |
|
|
saubhik
New User
Joined: 21 Sep 2007 Posts: 35 Location: kolkata
|
|
|
|
It would be great if you can give some example. |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
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 |
|
|
|