Home > Archive > Cobol > January 2005 > Displaying the contents of pointers in cobol...
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Displaying the contents of pointers in cobol...
|
|
| XPPROGRAMMER 2005-01-25, 3:55 pm |
| Hello,
how do I display the content of a data-pointer and pointer
items in cobol? Case in point:
01 data-pointer typedef pointer.
01 LPTSTR typedef usage data-pointer.
01 Array is typedef.
03 CBsize UINT.
03 Uflags UINT.
03 lpszText1 pointer.
03 uId UINT.
03 ToolRect RECT.
03 hinst HINSTANCE.
03 lpszText2 LPTSTR.
if lpszText1 and lpszText2 have received a text string,
how can I use the redefine clause to display the text?
thanks for the help.
| |
| epc8@juno.com 2005-01-26, 3:55 am |
| XPPROGRAMMER wrote:
> Hello,
>
> how do I display the content of a data-pointer and pointer
> items in cobol? Case in point:
>
> 01 data-pointer typedef pointer.
> 01 LPTSTR typedef usage data-pointer.
> 01 Array is typedef.
> 03 CBsize UINT.
> 03 Uflags UINT.
> 03 lpszText1 pointer.
> 03 uId UINT.
> 03 ToolRect RECT.
> 03 hinst HINSTANCE.
> 03 lpszText2 LPTSTR.
>
> if lpszText1 and lpszText2 have received a text string,
> how can I use the redefine clause to display the text?
> thanks for the help.
1. A pointer contains an address (or equivalent) so displaying its
contents will be of no help to you.
2. REDEFINES simply allows different views of the same data item, for
example both as a string of characters and as a string of digits. This
does not apply either.
3. It looks like you are calling a Windows API. Usually the details of
passing variables by reference are taken care of in the linkage section
and by the syntax of the CALL.
AFAIK, COBOL does not have an operator which de-references a pointer,
as you would do in C, which is something that returns what the pointer
is pointing at. So if you are actually passing a data structure which
contains pointers to a routine, then you have to point them at other
appropriate data structures yourself.
| |
| XPPROGRAMMER 2005-01-26, 3:55 am |
|
epc8@juno.com wrote:
> 1. A pointer contains an address (or equivalent) so displaying its
> contents will be of no help to you.
>
> 2. REDEFINES simply allows different views of the same data item, for
> example both as a string of characters and as a string of digits.
This
> does not apply either.
>
> 3. It looks like you are calling a Windows API. Usually the details
of
> passing variables by reference are taken care of in the linkage
section
> and by the syntax of the CALL.
>
> AFAIK, COBOL does not have an operator which de-references a pointer,
> as you would do in C, which is something that returns what the
pointer
> is pointing at. So if you are actually passing a data structure which
> contains pointers to a routine, then you have to point them at other
> appropriate data structures yourself.
John Wrote:
thanks for your reply.
john.
| |
| Richard 2005-01-26, 3:55 am |
| > how can I use the redefine clause to display the text?
The redefine won't be of any use. You dereference using LINKAGE
SECTION.
Create an appropriate record item in linkage section and (depending on
compiler):
SET ADDRESS OF linkage-record TO pointer-name
Then use linkage-record fields as if they were working-storage items.
| |
| XPPROGRAMMER 2005-01-26, 3:55 am |
|
Richard wrote:
>
> The redefine won't be of any use. You dereference using LINKAGE
> SECTION.
>
> Create an appropriate record item in linkage section and (depending
on
> compiler):
>
> SET ADDRESS OF linkage-record TO pointer-name
>
> Then use linkage-record fields as if they were working-storage items.
John Wrote:
thanks a lot richard, very clever solution.
John.
|
|
|
|
|