DocAda(tm) is a productivity tool of KSCE

Prev | Up | Next | Back | Forward
About DocAda Light: Preface / Preliminary / Help / TOC / Copyright
DocAda Online at the Ada Home: Complete RM95 / Updates / News

F.3.3 The Package Text_IO.Editing

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

The library package Text_IO.Editing has the following declaration:

   
       package Ada.Text_IO.Editing is

          type Picture is private;


          function Valid (Pic_String      : in String;
                          Blank_When_Zero : in Boolean := False) return Boolean;

          function To_Picture (Pic_String      : in String;
                               Blank_When_Zero : in Boolean := False)
             return Picture;

          function Pic_String      (Pic : in Picture) return String;
          function Blank_When_Zero (Pic : in Picture) return Boolean;

          Max_Picture_Length  : constant := implementation_defined;

          Picture_Error       : exception;

          Default_Currency    : constant String    := "$";
          Default_Fill        : constant Character := '*';
          Default_Separator   : constant Character := ',';
          Default_Radix_Mark  : constant Character := '.';

          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;

             function Valid (Item     : in Num;
                             Pic      : in Picture;
                             Currency : in String := Default_Currency)
                return Boolean;

             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;

             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);

             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;

The exception Constraint_Error is raised if the Image function or any of the Put procedures is invoked with a null string for Currency.

    
       function Valid (Pic_String      : in String;
                       Blank_When_Zero : in Boolean := False) return Boolean;
    
       function To_Picture (Pic_String      : in String;
                            Blank_When_Zero : in Boolean := False)
          return Picture;
    
       function Pic_String      (Pic : in Picture) return String;

       function Blank_When_Zero (Pic : in Picture) return Boolean;
    
       function Length (Pic      : in Picture;
                        Currency : in String := Default_Currency)
          return Natural;
    
       function Valid (Item     : in Num;
                       Pic      : in Picture;
                       Currency : in String := Default_Currency)
          return Boolean;
    
       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;
    
       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);
    
       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);

Implementation Requirements

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.

        The value of 30 for Max_Picture_Length is the same limit as in COBOL.

About DocAda Light: Preface / Preliminary / Help / TOC / Copyright
DocAda Online at the Ada Home: Complete RM95 / Updates / News
Prev | Up | Next | Back | Forward


Copyright © 1994-1997 by Kempe Software Capital Enterprises. All Rights Reserved. For comments on this DocAda(tm) hypertext document, please write to KSCE, at docada@ksce.com