Prev | Up | Next | Back | Forward
TOC -- / --.-- / --.--.-- | Index | Search | Syntax | Help


F.3.3 The Package Text_IO.Editing

(1)
The package Text_IO.Editing provides a private type Picture with associated operations, and a generic package Decimal_Output. An object of type Picture is composed from a well-formed picture String (see F.3.1) and a Boolean item indicating whether a zero numeric value will result in an edited output string of all space characters. The package Decimal_Output contains edited output subprograms implementing the effects defined in F.3.2.
Static Semantics
(2)
The library package Text_IO.Editing has the following declaration:
(3)
       package Ada.Text_IO.Editing is
(4)
          type Picture is private;

(5)
          function Valid (Pic_String      : in String;
                          Blank_When_Zero : in Boolean := False) return Boolean;
(6)
          function To_Picture (Pic_String      : in String;
                               Blank_When_Zero : in Boolean := False)
             return Picture;
(7)
          function Pic_String      (Pic : in Picture) return String;
          function Blank_When_Zero (Pic : in Picture) return Boolean;
(8)
          Max_Picture_Length  : constant := implementation_defined;
(9)
          Picture_Error       : exception;
(10)
          Default_Currency    : constant String    := "$";
          Default_Fill        : constant Character := '*';
          Default_Separator   : constant Character := ',';
          Default_Radix_Mark  : constant Character := '.';
(11)
          generic
             type Num is delta <> digits <>;
             Default_Currency   : in String    :=  Text_IO.Editing.Default_Currency;
             Default_Fill       : in Character :=  Text_IO.Editing.Default_Fill;
             Default_Separator  : in Character :=  Text_IO.Editing.Default_Separator;
             Default_Radix_Mark : in Character :=  Text_IO.Editing.Default_Radix_Mark;
          package Decimal_Output is
             function Length (Pic      : in Picture;
                              Currency : in String := Default_Currency)
                return Natural;
(12)
             function Valid (Item     : in Num;
                             Pic      : in Picture;
                             Currency : in String := Default_Currency)
                return Boolean;
(13)
             function Image (Item       : in Num;
                             Pic        : in Picture;
                             Currency   : in String    := Default_Currency;
                             Fill       : in Character := Default_Fill;
                             Separator  : in Character := Default_Separator;
                             Radix_Mark : in Character := Default_Radix_Mark)
                return String;
(14)
             procedure Put (File       : in File_Type;
                            Item       : in Num;
                            Pic        : in Picture;
                            Currency   : in String    := Default_Currency;
                            Fill       : in Character := Default_Fill;
                            Separator  : in Character := Default_Separator;
                            Radix_Mark : in Character := Default_Radix_Mark);
(15)
             procedure Put (Item       : in Num;
                            Pic        : in Picture;
                            Currency   : in String    := Default_Currency;
                            Fill       : in Character := Default_Fill;
                            Separator  : in Character := Default_Separator;
                            Radix_Mark : in Character := Default_Radix_Mark);
(16)
             procedure Put (To         : out String;
                            Item       : in Num;
                            Pic        : in Picture;
                            Currency   : in String    := Default_Currency;
                            Fill       : in Character := Default_Fill;
                            Separator  : in Character := Default_Separator;
                            Radix_Mark : in Character := Default_Radix_Mark);
          end Decimal_Output;
       private
          ... -- not specified by the language
       end Ada.Text_IO.Editing;
(17)
The exception Constraint_Error is raised if the Image function or any of the Put procedures is invoked with a null string for Currency.
(18)
       function Valid (Pic_String      : in String;
                       Blank_When_Zero : in Boolean := False) return Boolean;
(19)
(20)
       function To_Picture (Pic_String      : in String;
                            Blank_When_Zero : in Boolean := False)
          return Picture;
(21)
(22)
       function Pic_String      (Pic : in Picture) return String;

       function Blank_When_Zero (Pic : in Picture) return Boolean;
(23)
(24)
(25)
(26)
(27)
(28)
(29)
       function Length (Pic      : in Picture;
                        Currency : in String := Default_Currency)
          return Natural;
(30)
(31)
(32)
(33)
(34)
(35)
(36)
(37)
       function Valid (Item     : in Num;
                       Pic      : in Picture;
                       Currency : in String := Default_Currency)
          return Boolean;
(38)
(39)
       function Image (Item       : in Num;
                       Pic        : in Picture;
                       Currency   : in String    := Default_Currency;
                       Fill       : in Character := Default_Fill;
                       Separator  : in Character := Default_Separator;
                       Radix_Mark : in Character := Default_Radix_Mark)
          return String;
(40)
(41)
       procedure Put (File       : in File_Type;
                      Item       : in Num;
                      Pic        : in Picture;
                      Currency   : in String    := Default_Currency;
                      Fill       : in Character := Default_Fill;
                      Separator  : in Character := Default_Separator;
                      Radix_Mark : in Character := Default_Radix_Mark);

       procedure Put (Item       : in Num;
                      Pic        : in Picture;
                      Currency   : in String    := Default_Currency;
                      Fill       : in Character := Default_Fill;
                      Separator  : in Character := Default_Separator;
                      Radix_Mark : in Character := Default_Radix_Mark);
(42)
(43)
       procedure Put (To         : out String;
                      Item       : in Num;
                      Pic        : in Picture;
                      Currency   : in String    := Default_Currency;
                      Fill       : in Character := Default_Fill;
                      Separator  : in Character := Default_Separator;
                      Radix_Mark : in Character := Default_Radix_Mark);
(44)
Implementation Requirements
(45)
Max_Picture_Length shall be at least 30. The implementation shall support currency strings of length up to at least 10, both for Default_Currency in an instantiation of Decimal_Output, and for Currency in an invocation of Image or any of the Put procedures.

(46)
(47)
(48)
(49)
(50)
(51)
(52)
        The value of 30 for Max_Picture_Length is the same limit as in COBOL.

Prev | Up | Next | Back | Forward
TOC -- / --.-- / --.--.-- | Index | Search | Syntax | Help

Ada WWW Home -- Email comments, additions, corrections, gripes, kudos, etc. to:

Magnus Kempe -- Magnus.Kempe@di.epfl.ch
Copyright statement
Page last generated: 95-03-12