🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #367

Re: Too small field width

#367
From: Erland Sommarskog
Date: Thu, 27 Jul 1989 21:47
35 lines
2319 bytes
Richard Pattis (pattis@june.cs.washington.edu) writes:
>In Pascal, when one specifies a too small field width, my compiler prints the
>"*" character replicated to fill the field width.  My Modula-2 compiler
>prints the full value, in as few characters as possible, disregarding the
>field width if it is too small (0 is commonly used to mean "print the value
>in the fewest number of characters").

Strange compiler you have. All Pascal compilers I have dealt with
just expands the field so that the item fits. I don't have Wirth's
report around, but to me it sounds like your compiler deviates from
the standard. Fortran should behave in that way, I think, but not Pascal.

>Are there any languages/compilers out there that are known, in such a case,
>to keep the field width and print just some of value (for a number, either
>left or right truncated)?

Cobol. At least the report writer does so. At least in DEC's compiler
for VMS. Say you state that field should look like:
      z.zzz.zzz.zz9,99 BLANK WHEN ZERO
(The z means leave blank if they are zero. The dots and commas are
printed if they are preceeded by numbers. The BLANK WHEN ZERO prevents
0,00 from pop up.) Assume now that business goes better than expected
and your result is 10.043.967.234,32 in some currency. This will come up
as 43.967.234,32 in your report, which is not all nice. I haven't found
a way to tell Cobol that it should print stars or whatever in such a
case. The behaviour above is very dangerous, because if you don't have
a very clear idea what results you expect, you might very easily believe
that the truncated field is the actual value.
If there is to make VAX-Cobol behave differently please tell me, because 
we're using the report writer a lot in our project and really have
that problem.
-- 
Erland Sommarskog - ENEA Data, Stockholm - sommar@enea.se
"Apparently being a gnu adept and having a good sense of humor
are disjunct qualities." - Mart van Stiphout
Technical Details
Message-ID: <142@enea.se>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!mcvax!kth!sunic!enea!sommar

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!mcvax!kth!sunic!enea!sommar
From: sommar@enea.se (Erland Sommarskog)
Newsgroups: comp.lang.misc
Subject: Re: Too small field width
Message-ID: <142@enea.se>
Date: 27 Jul 89 21:47:24 GMT
Organization: Enea Data AB, Sweden
Lines: 35