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

Need sample to explain the usage of BASED


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

New User


Joined: 06 Jul 2007
Posts: 58
Location: home

PostPosted: Thu Oct 25, 2007 11:35 am
Reply with quote

Hi everybody here,
I am confused about the usage of BASED, please consider the following code:

Code:
DCL 1 DERIVED_AREA BASED(ADDR(DERIVED_STMT)) CHAR(4300);


I know DERIVED_AREA and DERIVED_STMT use the same memeroy area,
but could some friends here tell me :

Now that there is DERIVED_STMT as variable to proceed,why there is DERIVED_AREA ,what is DERIVED_AREA used for?

could someone here give me a sample to explain the usage of BASED?
Many thanks...
Back to top
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Thu Oct 25, 2007 12:08 pm
Reply with quote

Hi,
Consider a file read example.
A file can contain different record types. Based on certain indicator in the record, you will decide what record type it is.

DCL DERIVED_STMT CHAR(4300);

DCL 1 REC1 BASED(ADDR(DERIVED_STMT)),
record layout here.

DCL 1 REC2 BASED(ADDR(DERIVED_STMT)),
record layout here.

etc.

You will always read the file into DERIVED_STMT. But based on some particular field you will decide to which record type it belongs to and accordingly you will try to access the contents of the record.

Hope it helps.
Back to top
View user's profile Send private message
ruodeer

New User


Joined: 06 Jul 2007
Posts: 58
Location: home

PostPosted: Thu Oct 25, 2007 2:55 pm
Reply with quote

Hi ,Srihari.
thanks for your reply.
Back to top
View user's profile Send private message
donateeye
Warnings : 2

New User


Joined: 01 Jun 2007
Posts: 62
Location: chennai

PostPosted: Mon Dec 03, 2007 6:28 pm
Reply with quote

Let me help you in a simpler way.

if I say :

DCL X
DCL A BASED B

here the B should be a pointer variable and should be assigned a value like : B = ADDR(X)

now A shares the same storage of X, no matter A and X are same or different base and scales... B is a pointer which relates both....

Just like using DEFINE, but the difference is that, when you use DEFINE, you can relate two variables only if they are of same base and scale.
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 DB2 Statistics - Using EXPLAIN and qu... DB2 1
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 STEM usage in REXX CLIST & REXX 14
No new posts Split large FB file based on Key coun... DFSORT/ICETOOL 4
Search our Forums:

Back to Top