For Programmers: Free Programming Magazines  


Home > Archive > Cobol > January 2007 > TYPEDEF and RENAMES (was Re: Productivity)









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 TYPEDEF and RENAMES (was Re: Productivity)
Frank Swarbrick

2007-01-10, 6:55 pm

>
>
>
>"Frank Swarbrick" <Frank.Swarbrick@efirstbank.com> wrote in message
>news:50fnlaF1esfutU1@mid.individual.net...
>[snip]
>until
>
>It may be possible to avoid using OF (or IN) by using
>the 66 RENAMES.
>
>Change to TYP since TYPE is a reserved word.
> 66 PREV-TRAN-ACCT-NBR RENAMES ACCT-NBR.
> 66 PREV-TRAN-TYP RENAMES TYP.
> 66 PREV-TRAN-AMOUNT RENAMES AMOUNT.
> 66 TRAN-ACCT-NBR RENAMES ACCT-NBR.
> 66 TRAN-TYP RENAMES TYP.
> 66 TRAN-AMOUNT RENAMES AMOUNT.
>
>Replace the "." separator with "-" in the following.
>
:-)[color=darkred]
>
>However 66 RENAMES can not be used with entries
>subordinate to an OCCURS clause or an 88 condition-name.
>
>TYPEDEFs may be used to maintain consistent USAGE
>and PICTURE, yet, with 66 RENAMES, allow most
>procedure division statements to avoid the use of OF or IN.
>
>[I checked the above statements using Micro Focus 3.2.24
>(where TYPEDEF is an extension) and by reading the FDIS
>for COBOL 2002.]


Even more typing! Thanks, but no. :-)

Frank
Rick Smith

2007-01-10, 6:55 pm


"Frank Swarbrick" <Frank.Swarbrick@efirstbank.com> wrote in message
news:50ki2hF1g4q80U1@mid.individual.net...
> :-)
>
> Even more typing! Thanks, but no. :-)


I do not understand!

TYPEDEF saves several hundred (maybe a few thousand)
characters. OF (or IN) adds a few hundred to several hundred
characters. Judicious use of RENAMES adds a few hundred;
but saves a few hundred to several hundred characters by
avoiding OF (or IN). [Depending on the program.]

The key, it seems, is that, where the judicious use of RENAMES
adds fewer characters than are saved by using TYPEDEF, the
result will be less typing. Therefore, I do not understand how
less typing would be "Even more typing!".

Perhaps you could explain your comment.



Frank Swarbrick

2007-01-10, 6:55 pm

Rick Smith<ricksmith@mfi.net> 01/10/07 12:45 PM >>>
>
>"Frank Swarbrick" <Frank.Swarbrick@efirstbank.com> wrote in message
>news:50ki2hF1g4q80U1@mid.individual.net...
TYPEDEFs[color=darkred]
>
>I do not understand!
>
>TYPEDEF saves several hundred (maybe a few thousand)
>characters. OF (or IN) adds a few hundred to several hundred
>characters. Judicious use of RENAMES adds a few hundred;
>but saves a few hundred to several hundred characters by
>avoiding OF (or IN). [Depending on the program.]
>
>The key, it seems, is that, where the judicious use of RENAMES
>adds fewer characters than are saved by using TYPEDEF, the
>result will be less typing. Therefore, I do not understand how
>less typing would be "Even more typing!".
>
>Perhaps you could explain your comment.


I think we may be on two different pages. I was comparing yours:

01 TRANSACTION TYPEDEF.
05 ACCT-NBR PIC 9(10).
05 TYP PIC X.
05 AMOUNT PIC S9(9)V99 COMP-3.

01 PREV-TRAN TYPE TRANSACTION.
66 PREV-TRAN-ACCT-NBR RENAMES ACCT-NBR.
66 PREV-TRAN-TYP RENAMES TYP.
66 PREV-TRAN-AMOUNT RENAMES AMOUNT.

01 TRAN TYPE TRANSACTION.
66 TRAN-ACCT-NBR RENAMES ACCT-NBR.
66 TRAN-TYP RENAMES TYP.
66 TRAN-AMOUNT RENAMES AMOUNT.

IF TRAN-ACCT-NBR = PREV-TRAN-ACCT-NBR
CONTINUE
ELSE
PERFORM ACCT-BREAK
MOVE TRAN TO PREV-TRAN
MOVE ZERO TO TOTAL-TRAN-AMOUNT
END-IF
ADD TRAN-AMOUNT TO TOTAL-TRAN-AMOUNT

With my "pseudo-COBOL" version.

01 TRANSACTION TYPEDEF.
05 ACCT-NBR PIC 9(10).
05 TYP PIC X.
05 AMOUNT PIC S9(9)V99 COMP-3.

01 PREV-TRAN TYPE TRANSACTION.
01 TRAN TYPE TRANSACTION.

IF TRAN.ACCT-NBR = PREV-TRAN.ACCT-NBR
CONTINUE
ELSE
PERFORM ACCT-BREAK
MOVE TRAN TO PREV.TRAN
MOVE ZERO TO TOTAL-TRAN-AMOUNT
END-IF
ADD TRAN.AMOUNT TO TOTAL-TRAN-AMOUNT

Whereas I think you must have been comparing yours versus a version not
using TYPEDEF.

Or were you comparing it to this?
01 TRANSACTION TYPEDEF.
05 ACCT-NBR PIC 9(10).
05 TYP PIC X.
05 AMOUNT PIC S9(9)V99 COMP-3.

01 PREV-TRAN TYPE TRANSACTION.
01 TRAN TYPE TRANSACTION.

IF ACCT-NBR OF TRAN = ACCT-NBR OF PREV-TRAN
CONTINUE
ELSE
PERFORM ACCT-BREAK
MOVE TRAN TO PREV-TRAN
MOVE ZERO TO TOTAL-TRAN-AMOUNT
END-IF
ADD AMOUNT OF TRAN TO TOTAL-TRAN-AMOUNT

Even that version is less typing than your version.

What I was saying is that, you are typing "ALT-FIELD-NAME RENAMES
FIELD-NAME" in order to be able to say "MOVE ALT-FIELD-NAME TO ..." instead
of "MOVE FIELD-NAME OF XXX TO...". It looks like more typing to me.

I'm probably just not understanding what you are getting at.

Frank




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

2007-01-10, 9:55 pm


"Frank Swarbrick" <Frank.Swarbrick@efirstbank.com> wrote in message
news:50l8a0F1gbnbdU1@mid.individual.net...
> Rick Smith<ricksmith@mfi.net> 01/10/07 12:45 PM >>>
> TYPEDEFs
>
> I think we may be on two different pages. I was comparing yours:
>
> 01 TRANSACTION TYPEDEF.
> 05 ACCT-NBR PIC 9(10).
> 05 TYP PIC X.
> 05 AMOUNT PIC S9(9)V99 COMP-3.
>
> 01 PREV-TRAN TYPE TRANSACTION.
> 66 PREV-TRAN-ACCT-NBR RENAMES ACCT-NBR.
> 66 PREV-TRAN-TYP RENAMES TYP.
> 66 PREV-TRAN-AMOUNT RENAMES AMOUNT.
>
> 01 TRAN TYPE TRANSACTION.
> 66 TRAN-ACCT-NBR RENAMES ACCT-NBR.
> 66 TRAN-TYP RENAMES TYP.
> 66 TRAN-AMOUNT RENAMES AMOUNT.
>
> IF TRAN-ACCT-NBR = PREV-TRAN-ACCT-NBR
> CONTINUE
> ELSE
> PERFORM ACCT-BREAK
> MOVE TRAN TO PREV-TRAN
> MOVE ZERO TO TOTAL-TRAN-AMOUNT
> END-IF
> ADD TRAN-AMOUNT TO TOTAL-TRAN-AMOUNT
>
> With my "pseudo-COBOL" version.
>
> 01 TRANSACTION TYPEDEF.
> 05 ACCT-NBR PIC 9(10).
> 05 TYP PIC X.
> 05 AMOUNT PIC S9(9)V99 COMP-3.
>
> 01 PREV-TRAN TYPE TRANSACTION.
> 01 TRAN TYPE TRANSACTION.
>
> IF TRAN.ACCT-NBR = PREV-TRAN.ACCT-NBR
> CONTINUE
> ELSE
> PERFORM ACCT-BREAK
> MOVE TRAN TO PREV.TRAN
> MOVE ZERO TO TOTAL-TRAN-AMOUNT
> END-IF
> ADD TRAN.AMOUNT TO TOTAL-TRAN-AMOUNT
>
> Whereas I think you must have been comparing yours versus a version not
> using TYPEDEF.
>
> Or were you comparing it to this?
> 01 TRANSACTION TYPEDEF.
> 05 ACCT-NBR PIC 9(10).
> 05 TYP PIC X.
> 05 AMOUNT PIC S9(9)V99 COMP-3.
>
> 01 PREV-TRAN TYPE TRANSACTION.
> 01 TRAN TYPE TRANSACTION.
>
> IF ACCT-NBR OF TRAN = ACCT-NBR OF PREV-TRAN
> CONTINUE
> ELSE
> PERFORM ACCT-BREAK
> MOVE TRAN TO PREV-TRAN
> MOVE ZERO TO TOTAL-TRAN-AMOUNT
> END-IF
> ADD AMOUNT OF TRAN TO TOTAL-TRAN-AMOUNT
>
> Even that version is less typing than your version.
>
> What I was saying is that, you are typing "ALT-FIELD-NAME RENAMES
> FIELD-NAME" in order to be able to say "MOVE ALT-FIELD-NAME TO ..."

instead
> of "MOVE FIELD-NAME OF XXX TO...". It looks like more typing to me.
>
> I'm probably just not understanding what you are getting at.


Assuming TYPEDEF is used, then with regard to typing,
the total number of characters that will be used depends
upon the frequency of reference in a complete program;
not in code used as an example. If it is correctly anticipated
that qualification will be used frequently with particular
data-names and those data-names are renamed, there
will be less typing. I hope that is clear. <g>



William M. Klein

2007-01-18, 6:55 pm

TYPEDEFs ...
Just wanted to make certain that those thinking about using the ISO 2002
enhancement of "TYPEDEFs" also look at the implications of "strong" and "weak"
typing in that Standard. I haven't checked it, but I *think* that SAME AS in
the '02 Standard does NOT introduce those restrictions or advantages (depending
upon your view of STRONG typing).

--
Bill Klein
wmklein <at> ix.netcom.com


Sponsored Links







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

Copyright 2008 codecomments.com