Re: Converting Type Characters to type string



On Mon, 31 Mar 2008 01:54:24 -0700 (PDT), Ludovic Brenta wrote:

As a matter of general principle, I always use a for loop when
traversing an array:

procedure Get_Digits (Result : out String; Last : out Natural);
-- Reads at most Result'Length characters from standard input. Stops
-- after the first character that is not a decimal digit.
-- On output, Result (Result'First .. Last) contains the digits from stdin;
-- Last may be zero, indicating no digits entered (i.e. one character that
-- is not a digit was read).

(or none, on End_Error, Data_Error etc)

Such Get_Digits is not composable, without a sort of "unget," which
Ada.Text_IO does not have.

I believe it was a bad (FORTRAN?) idea to intermix I/O with parsing /
syntax analysis. Though it had one theoretical advantage of being able to
deal with lines of an unlimited length, in real life that never worked
anyway. (Like in your example, it would not).

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.



Relevant Pages

  • Re: Fortran decimal anyone?
    ... One Decimal Digit per Byte Data Formats. ... In some cases, the sign indication, if present, was a separate ... character -- a minus sign or a plus sign in the ... A leading separate character as in, ...
    (comp.lang.fortran)
  • RE: Excel column width question again
    ... do not need to determine what font and point size to use. ... Truncate(128/{Maximum Digit Width}))/256)*)' to ... 100+0.5)/100 to convert pixel to character number. ... Microsoft Online Community Support ...
    (microsoft.public.office.developer.com.add_ins)
  • Re: embarrassing spaghetti code needs stylistic advice
    ... assumes that there is a character in CH which ... necessary using RCH, and it calls RCH at least once so that, when it ... You seem very worried about reading in an EOF character. ... Either '+' is followed by a digit, ...
    (comp.lang.c)
  • Re: Mod 43 Check Digit calculator
    ... miscalculation of the check digit. ... > response to you) should return the check character itself rather than> the ... Here is that formula with the absolute reference problem> that ... > space in the encoding string at the 39th position. ...
    (microsoft.public.excel.programming)
  • Re: Need Help.
    ... '0') from a character to change it to a number, do your calculation, and add 30h to the number to make it a character before displaying it. ... If you want to accept multiple digit numbers as input... ... Once you can display a correct answer all the way up to 9 + 9, I think you'll find it easy to extend it to multiplication. ...
    (comp.lang.asm.x86)