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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a05:620a:54b:: with SMTP id o11mr7215818qko.152.1587922426947; Sun, 26 Apr 2020 10:33:46 -0700 (PDT) X-Received: by 2002:a9d:1a6:: with SMTP id e35mr14889888ote.240.1587922426546; Sun, 26 Apr 2020 10:33:46 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 26 Apr 2020 10:33:46 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=70.109.61.2; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 70.109.61.2 References: <26e971a9-6fcc-4e4c-84ee-d74aecd5b217@googlegroups.com> <2c769c87-72f2-4107-b0bf-3846e3ae6c7a@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <670160da-e66d-446f-a415-27df39d9a73f@googlegroups.com> Subject: Re: Image attribute (yet again) From: Jere Injection-Date: Sun, 26 Apr 2020 17:33:46 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:58499 Date: 2020-04-26T10:33:46-07:00 List-Id: On Sunday, April 26, 2020 at 1:09:12 PM UTC-4, Jeffrey R. Carter wrote: > On 4/26/20 4:16 PM, Jere wrote: > >> > > This might be a good time to ask since this comes up all the time > > for me, but where are the formatting options for hexadecimal > > to String. All I have found so far is the Put operation > > in the various "_IO" packages and generics, but it isn't > > useful at all for formatting hexadecimal values in real world > > scenarios. I pretty much reinvent the wheel each time > > I have some variant of needing this functionality. One of > > these days I'll get around to making my own generic > > version of it, but if the Ada standard provides a means > > to do it, that would be optimal. The only option I have > > found is the Put operation, but it is pretty abysmal to > > use. Are there any solutions to this that I am missing > > from within the Ada standard? > > I can't tell what problem you're talking about. Ada.Text_IO's numeric-I/O pkgs, > sometimes combined with String-handling functions and basic 1-D array operations > seem to provide everything one could want. > I'm not saying it can't be done. I'm saying by the time I go through all the processing needed, I might as well wrote my own function. It makes the existing operation mostly useless (unless I just want a temporary debug print that I don't care how it looks). For example, if I want to print to a 16x2 character LCD screen and I want to print 0 padded 4 digit hex values with no "16#" prefix or "#" ending, then I need to call Put with an 8 character string, search for the first occurrence of '#' (it can be in multiple locations), then overwrite a variable number of those characters with 0's (based on the location of '#'), and then extract the 4 digits I actually need. All doable (not saying it cannot be done), but at that point, I am better off just doing my own custom operation instead instead of even using the Put operation. It feels like the Put operation wasn't designed with usability in mind. Just the presence of the "16#" and "#" around the value makes using the operation more clunky than it should be. If that had been left out or if the operation at least allowed for padding the actual numeric value inside the result, then it would have been much more usable. I was hoping that there was a better formatting operation for non base 10 number formatting that I wasn't aware of as it was alluded that Text_IO had all the necessary formatting features. I am still finding new stuff in the Ada standard each day, so I was hoping I had just missed something. J.P. Rosen has a much better experience and knowledge of the standard than me, so I was hoping he could point me to something that was better than what I currently knew of. If there isn't, then no biggie, I'll just keep writing custom functions.