View previous topic :: View next topic
|
Author |
Message |
satishboddu
New User
Joined: 02 Aug 2011 Posts: 17 Location: India
|
|
|
|
Hi All,
I have two variables with data as below.
01 WS-AB PIC X(02) VALUE 'AB'.
01 WS-CD PIC X(02) VALUE 'CD'.
I like to refer data 'CD' to variable WS-AB by using cobol pointers.
Please let me know how can I achieve this.
Thanks |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
It is unclear from your description what it is that you want.
Why do you want to do it?
What do you want to achieve?
What is wrong with MOVE? |
|
Back to top |
|
|
Eshwar CICS
New User
Joined: 18 May 2011 Posts: 47 Location: India
|
|
|
|
Are the variables which you have mentioned reside in working storage? |
|
Back to top |
|
|
satishboddu
New User
Joined: 02 Aug 2011 Posts: 17 Location: India
|
|
|
|
Hi All,
I have two variables with data as below.
01 WS-AB PIC X(02) VALUE ‘123’.
01 WS-CD PICX(02) VALUE ‘345’
01 WS-F PIC X(08) VALUE.
MOVE “WS-AB” to WS-F, is populated in another program.
Based on variable name that’s in WS-F, we want to retrieve the value of that variable.
Suppose, we have WS-AB as variable in WS-F, we need 123 and if WS-CD in the variable, we are looking for 345.
I have heard pointers can be used to do this.
Please suggest .. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
since in any case You have to use an if to <load> the pointer with the proper address why bother |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
There is no fancy way to dynamically obtain the address/contents of a Cobol data-name from a piece of text.
Test the value of the text, and code out the MOVEs for the appropriate value. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
another case of pc language skills - not able to read the manual.
cobol resolves the contents of areas indirectly addressed by use of pointers.
cobol always treats the contents of a variable as the contents of a variable.
cobol treats the contents of a pointer as the address of a variable.
that is the way that it is done. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Using POINTER's to address WS fields was not introduced until OS/390 COBOL 2.2.1, about 10-12 years ago.
If your COBOL version/release is less than the above, then you're out of luck.
Mr. Bill |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Bill,
you are correct.
COBOL 2 still disallows SETing a POINTER TO ADDRESS OF Variable in W-S.
but, you can CALL a module with two parms in the using list:
W-S
POINTER
and the CALLed module simply SETs the POINTER in linkage TO ADDRESS OF Variable in linkage,
and returns. |
|
Back to top |
|
|
Eshwar CICS
New User
Joined: 18 May 2011 Posts: 47 Location: India
|
|
|
|
Satish,
My opinion is that compiler has no role to play in this context.Basically get clarity on how working storage gets allocated and understand how pointers can be used in COBOL w.r.t linkage variables.Then you can decide on the feasibility of implementing your requirement. Thanks. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Dick,
Yes, you're right.
Many moons ago, had both an Assembler sub-program and COBOL sub-program which did this.
But to tell you the truth, I still don't know what the OP is trying to accomplish.
If the concept of obtaining addresses and traversing control blocks is foreign to the OP, my suggestion is to stay away from this and KISS.
As Bill W. expressed, what's wrong with a MOVE?
Mr. Bill |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
you can do that kind of silliness in java, c, c+, vb. |
|
Back to top |
|
|
|