From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,22b2c05a8088bbb2 X-Google-Attributes: gid103376,public From: rav@goanna.cs.rmit.edu.au (robin) Subject: Re: Leading zeros with Int_IO.Put()? Or another package? Date: 1996/11/19 Message-ID: <56rfv3$q2b$1@goanna.cs.rmit.edu.au>#1/1 X-Deja-AN: 197379698 expires: 20 February 1997 00:00:00 GMT references: <327FB8A3.745B@itg-sepg.logicon.com> <55ubsh$lh0$1@goanna.cs.rmit.edu.au> <56bg5v$14u$1@goanna.cs.rmit.edu.au> <328A0A7D.21A2@lmtas.lmco.com> organization: Comp Sci, RMIT, Melbourne, Australia newsgroups: comp.lang.ada nntp-posting-user: rav Date: 1996-11-19T00:00:00+00:00 List-Id: Ken Garlington writes: >robin wrote: >> >> dewar@merv.cs.nyu.edu (Robert Dewar) writes: >> >> >robin says >> >> >>"Interface to PL/I and you can use standard I/O: >> >> >>put edit (n) (P'-99999999'); >> >> >>and you don't have to worry about whether the number is >> >>negative either. The nines in the picture format >> >>force leading zeros to print. >> >> >>And if you want, you can insert commas in the output >> >>to make it more readable. The picture specification becomes: >> >> >I guess robin knows PL/1 and does not know Ada! >> >> >If you want to use picture editing to solve this kind of problem, then >> >use the picture editing in Ada, no need to wander off into PL/1, even in >> >the unlikely case that you have a PL/1 compiler at hand. Personally I >> >dislike the picture stuff in PL/1, they tried to improve on COBOL and >> >made a mess of it. >> >> Isn't it amazing! Robert Dewar [among others] already has >> had an opportunity to reply in this vein to the original >> posting and subsequent ones, but it didn't occur to him to >> do so, more than likely because he didn't know that a limited >> facility existed in Ada. Instead, he suggested using >> string facilities. >Actually, if you know Ada, it's not amazing at all. The Ada picture I/O is for >decimal types; the original request was for integer types. If you don't want to >convert your type, Really! The task is to convert to string type. You're saying that that's not a type conversion. the suggestion by Dr. Dewar is more straight-forward. If you >do want to use picture I/O, you probably still want to use an abstraction of >this facility to hide the details of type conversion, instantiation of picture I/O, >etc. >Ada people have this perversity of suggesting the most straight-forward and >maintainable approach first. :) >> >> Below is Robert Dewar's previous posting: >> >> >This is a place where CLEARLY there is a missing abstraction (Put with >> >leading zeros), and it seems obvious that you fix this in the way that >> >you always do abstraction extension, you create an appropriate abstraction >> >and use it. If it is useful enough, hopefully it gets to be widely available. >> >> >Note that if you do want to construct on the fly, a much clearer way is to >> >use the string routines from the string packages, which have padding >> >capabilities. >> >> PL/I is not restricted to picture editing with decimal data, >> (one poster suggested changing to Ada decimal data in order to use >> Ada's limited editing). PL/I requires *only* the single line: >> >> put edit (n) (P'-99999999'); >> >> and not the (up to) page of Ada code to implement the >> requirement of the original post.