TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: DANIEL JAMES
from: MARTIN GREGORIE
date: 2020-03-12 14:44:00
subject: Re: self hosting on the P

On Thu, 12 Mar 2020 13:58:14 +0000, Daniel James wrote:

> In article , Martin Gregorie wrote:
>> Think how much code you'd need in any other language to get the same
>> print formatting as the single COBOL declaration:
>>
>> 05 INVOICE-TOTAL  PIC "Z(4)9.99CR" BLANK WHEN ZERO.
>>
> The data division in COBOL is one of the very few forward-looking
> features of that language -- a declarative description of the variables
> used in the program. The clever bit, from the point of view of your
> example, is that this declaration included the external representation
> of the variable. Not always what you want but, for the sort of thing
> that COBOL got used for, occasionally very useful.
>
For printed totals and similar, that would be embedded in a print line
definition, so you populate the line with MOVE statements and then
WRITE ...AFTER to output it.

Worse, every data item thats read in, used and then written out to a
different destination gets defined three times: once in the input record,
secondly in WORKING STORAGE, and thirdly in the output record(s) it
should appear in. and there tends to be at least one MOVE statement for
each of these appearances. This is why COBOL programs that do anything
significant are big.

The first COBOL implementations tended to require programs to be
monolithic. ICL 1900 compilers would not accept programs with more than
12000 lines. Fortunately anything much over 5-6000 lines was rare, but
with all the other verbiage you seldom saw an externally defined
subroutine of under 300 lines or a free-standing program of under 1000.


> I've just looked up how the CR thing worked ... so CR and DB (meaning
> credit or debit) both apply to negative numbers, and you define which to
> use depending on which side of a balance sheet you're working ... that's
> the sort of warped thinking that gets accountants a bad name!
>
You got it, and don't forget the option of inserting commas at the
thousand, million and billion points.

Fortunately, in this day an age, using, say, Java it would be easy to
define a set of static numeric formatting methods for financial values
and wrap them in a Class declaration for convenience. Once you get to
financial input andf display, you really want to let the users abbreviate
as much as possible, so you might want to accept something like any of
$1.5B , USD1.5B, 1500M USD  or 1,500,000,000.00 USD as all meaning one
and a half billion US dollars while holding the value internally as
binary cents in a signed 64 bit integer or a BigInteger.


--
Martin    | martin at
Gregorie  | gregorie dot org

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.