For Programmers: Free Programming Magazines  


Home > Archive > Cobol > January 2007 > Use of better qualification related to Re: TYPEDEF and RENAMES









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 Use of better qualification related to Re: TYPEDEF and RENAMES
Frank Swarbrick

2007-01-11, 6:55 pm

Clark F Morris<cfmpublic@ns.sympatico.ca> 01/10/07 6:44 PM >>>
>On Wed, 10 Jan 2007 19:10:37 -0500, "Rick Smith" <ricksmith@mfi.net>
>wrote:
>
existing[color=darkred]
to[color=darkred]
often.[color=darkred]
>
>This raises a sore point with me. IBM z series Assembler, C/C++, and
>DYL280 (now Vision something or another) have group-name.field-name
>instead of the awkward field-name of group-name. For English
>(including the off-spring US and Canadian variants) speakers, this is
>a more natural means of expression. In COBOL this of course would
>include file-name.group-name-1.group-name-2.field-name and all other
>things you can do with OF/IN. I still resent not having the
>capability. If the period causes a problem use another special
>character.


Someone on my side! Thank you! :-)

I find it somewhat interesting that even the DB2 pre-compiler for COBOL uses
the 'dot' separator for this kind of thing. Here's a quote from the DB2
"Programming Client Applications" manual

"
01 staff-record.
05 staff-id pic s9(4) comp-5.
05 staff-name.
49 l pic s9(4) comp-5.
49 d pic x(9).
05 staff-info.
10 staff-dept pic s9(4) comp-5.
10 staff-job pic x(5).

The second way of using group data items:
EXEC SQL SELECT id, name, dept, job
INTO :staff-record.staff-id,
:staff-record.staff-name,
:staff-record.staff-info.staff-dept,
:staff-record.staff-info.staff-job
FROM staff
WHERE id = 10
END-EXEC.
Note: The reference to staff-id is qualified with its group name using the
prefix staff-record., and not staff-id of staff-record as in pure COBOL."

One thing where I sort of like how COBOL works is that you don't have to
specify each 'level'. You can specify just enough to make it un-ambiguous.
For instance, given the above copybook we can reference just "staff-job" and
not have to do "staff-job of staff-info of staff-record." In C you might
have

struct {
int staff_id;
char staff_name[10];
struct {
int staff_dept;
char staff_job[6];
} staff_info;
} staff_record;

staff_record.staff_id = 1;
staff_record.staff_info.staff_dept = 10;

In C you have to use all of the qualifiers, whereas in COBOL you can just
use the field name (staff_info), as long as it's unique within the source
module. I certainly would not want to use every group level name. In the
above example I'd like to use staff-record.staff-job (actually, I'd probably
get rid of the 'staff-' prefix except at the 01 level, and just have
staff-record.job), but I wouldn't really care for typing
staff-record.staff-info.staff-job, or even staff-record.info.job. Though to
be honest, with Visual Studio even that is not too bad, because it pretty
much types it for you! :-)

I definitely would prefer to type MOVE 'FRANK' TO STAFF-NAME.D to typing
MOVE 'FRANK' TO D OF STAFF-NAME.

Ah well.

Frank



---
Frank Swarbrick
Senior Developer/Analyst - Mainframe Applications
FirstBank Data Corporation - Lakewood, CO USA

2007-01-11, 6:55 pm

In article <50nf11F1gtfkvU1@mid.individual.net>,
Frank Swarbrick <Frank.Swarbrick@efirstbank.com> wrote:

[snip]

>The second way of using group data items:
> EXEC SQL SELECT id, name, dept, job
> INTO :staff-record.staff-id,
> :staff-record.staff-name,
> :staff-record.staff-info.staff-dept,
> :staff-record.staff-info.staff-job
> FROM staff
> WHERE id = 10
> END-EXEC.
>Note: The reference to staff-id is qualified with its group name using the
>prefix staff-record., and not staff-id of staff-record as in pure COBOL."


Ahhhhhh, there it is... thanks much, Mr Swarbrick.

DD

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com