1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - The Package Text_IO.Editing</TITLE>
<META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
<META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
<STYLE type="text/css">
DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
TT {font-family: "Courier New", monospace}
DT {display: compact}
DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Index {font-family: "Times New Roman", Times, serif}
DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left: 10.0em; margin-bottom: 0.6em}
DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 15.0em; margin-bottom: 0.6em}
UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
DD.Hanging {margin-left: 6.0em}
DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.IndentedHanging {margin-left: 2.0em}
DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.HangingInBulleted {margin-left: 4.0em}
DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallHanging {margin-left: 7.5em}
DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallIndentedHanging {margin-left: 2.0em}
DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallHangingInBulleted {margin-left: 5.0em}
DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.Enumerated {margin-left: 2.0em}
DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallEnumerated {margin-left: 2.5em}
DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
</STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-F-3-2.html">Previous</A> <A HREF="AA-F-3-4.html">Next</A></P>
<HR>
<H1> F.3.3 The Package Text_IO.Editing</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> 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 <A HREF="AA-F-3-1.html">F.3.1</A>) 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 <A HREF="AA-F-3-2.html">F.3.2</A>.
</DIV>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> The library package
Text_IO.Editing has the following declaration: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="Examples"><TT><B>package</B> Ada.Text_IO.Editing <B>is</B><A NAME="I7085"></A><A NAME="I7086"></A><A NAME="I7087"></A></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> <A NAME="I7088"></A><A NAME="I7089"></A>Picture <B>is</B> <B>private</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I7090"></A><A NAME="I7091"></A>Valid (Pic_String : <B>in</B> String;<BR>
Blank_When_Zero : <B>in</B> Boolean := False) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I7092"></A><A NAME="I7093"></A>To_Picture (Pic_String : <B>in</B> String;<BR>
Blank_When_Zero : <B>in</B> Boolean := False)<BR>
<B>return</B> Picture;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I7094"></A><A NAME="I7095"></A>Pic_String (Pic : <B>in</B> Picture) <B>return</B> String;<BR>
<B>function</B> <A NAME="I7096"></A><A NAME="I7097"></A>Blank_When_Zero (Pic : <B>in</B> Picture) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Examples"><TT> <A NAME="I7098"></A>Max_Picture_Length : <B>constant</B> := <I>implementation_defined</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Examples"><TT> <A NAME="I7099"></A>Picture_Error : <B>exception</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Examples"><TT> <A NAME="I7100"></A>Default_Currency : <B>constant</B> String := "$";<BR>
<A NAME="I7101"></A>Default_Fill : <B>constant</B> Character := '*';<BR>
<A NAME="I7102"></A>Default_Separator : <B>constant</B> Character := ',';<BR>
<A NAME="I7103"></A>Default_Radix_Mark : <B>constant</B> Character := '.';</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Examples"><TT> <B>generic</B><BR>
<B>type</B> Num <B>is</B> <B>delta</B> <> <B>digits</B> <>;<BR>
Default_Currency : <B>in</B> String := Text_IO.Editing.Default_Currency;<BR>
Default_Fill : <B>in</B> Character := Text_IO.Editing.Default_Fill;<BR>
Default_Separator : <B>in</B> Character :=<BR>
Text_IO.Editing.Default_Separator;<BR>
Default_Radix_Mark : <B>in</B> Character :=<BR>
Text_IO.Editing.Default_Radix_Mark;<BR>
<B>package</B> <A NAME="I7104"></A>Decimal_Output <B>is</B><BR>
<B>function</B> <A NAME="I7105"></A><A NAME="I7106"></A>Length (Pic : <B>in</B> Picture;<BR>
Currency : <B>in</B> String := Default_Currency)<BR>
<B>return</B> Natural;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I7107"></A><A NAME="I7108"></A>Valid (Item : <B>in</B> Num;<BR>
Pic : <B>in</B> Picture;<BR>
Currency : <B>in</B> String := Default_Currency)<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I7109"></A><A NAME="I7110"></A>Image (Item : <B>in</B> Num;<BR>
Pic : <B>in</B> Picture;<BR>
Currency : <B>in</B> String := Default_Currency;<BR>
Fill : <B>in</B> Character := Default_Fill;<BR>
Separator : <B>in</B> Character := Default_Separator;<BR>
Radix_Mark : <B>in</B> Character := Default_Radix_Mark)<BR>
<B>return</B> String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I7111"></A><A NAME="I7112"></A>Put (File : <B>in</B> File_Type;<BR>
Item : <B>in</B> Num;<BR>
Pic : <B>in</B> Picture;<BR>
Currency : <B>in</B> String := Default_Currency;<BR>
Fill : <B>in</B> Character := Default_Fill;<BR>
Separator : <B>in</B> Character := Default_Separator;<BR>
Radix_Mark : <B>in</B> Character := Default_Radix_Mark);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I7113"></A><A NAME="I7114"></A>Put (Item : <B>in</B> Num;<BR>
Pic : <B>in</B> Picture;<BR>
Currency : <B>in</B> String := Default_Currency;<BR>
Fill : <B>in</B> Character := Default_Fill;<BR>
Separator : <B>in</B> Character := Default_Separator;<BR>
Radix_Mark : <B>in</B> Character := Default_Radix_Mark);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Examples" Style="margin-bottom: 0.9em"><TT> <B>procedure</B> <A NAME="I7115"></A><A NAME="I7116"></A>Put (To : <B>out</B> String;<BR>
Item : <B>in</B> Num;<BR>
Pic : <B>in</B> Picture;<BR>
Currency : <B>in</B> String := Default_Currency;<BR>
Fill : <B>in</B> Character := Default_Fill;<BR>
Separator : <B>in</B> Character := Default_Separator;<BR>
Radix_Mark : <B>in</B> Character := Default_Radix_Mark);<BR>
<B>end</B> Decimal_Output;<BR>
<B>private</B><BR>
... <I>-- not specified by the language</I><BR>
<B>end</B> Ada.Text_IO.Editing;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation defined: </B>The
value of Max_Picture_Length in the package Text_IO.Editing</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.9em"> The exception Constraint_Error
is raised if the Image function or any of the Put procedures is invoked
with a null string for Currency. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Valid (Pic_String : <B>in</B> String;<BR>
Blank_When_Zero : <B>in</B> Boolean := False) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">Valid returns
True if Pic_String is a well-formed picture String (see <A HREF="AA-F-3-1.html">F.3.1</A>)
the length of whose expansion does not exceed Max_Picture_Length, and
if either Blank_When_Zero is False or Pic_String contains no '*'.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> To_Picture (Pic_String : <B>in</B> String;<BR>
Blank_When_Zero : <B>in</B> Boolean := False)<BR>
<B>return</B> Picture;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">To_Picture returns
a result Picture such that the application of the function Pic_String
to this result yields an expanded picture String equivalent to Pic_String,
and such that Blank_When_Zero applied to the result Picture is the same
value as the parameter Blank_When_Zero. Picture_Error is raised if not
Valid(Pic_String, Blank_When_Zero).</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Pic_String (Pic : <B>in</B> Picture) <B>return</B> String;<BR>
<BR>
<B>function</B> Blank_When_Zero (Pic : <B>in</B> Picture) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.4em">If Pic is To_Picture(String_Item,
Boolean_Item) for some String_Item and Boolean_Item, then: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<UL Class="CodeIndentedBulleted"><LI TYPE=DISC>Pic_String(Pic) returns an expanded picture String equivalent
to String_Item and with any lower-case letter replaced with its corresponding
upper-case form, and</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>25</FONT></DIV>
<UL Class="CodeIndentedBulleted"><LI TYPE=DISC>Blank_When_Zero(Pic) returns Boolean_Item. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>26</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.4em">If Pic_1 and
Pic_2 are objects of type Picture, then "="(Pic_1, Pic_2) is
True when </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<UL Class="CodeIndentedBulleted"><LI TYPE=DISC>Pic_String(Pic_1) = Pic_String(Pic_2), and</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<UL Class="CodeIndentedBulleted" Style="margin-bottom: 0.7em"><LI TYPE=DISC>Blank_When_Zero(Pic_1) = Blank_When_Zero(Pic_2). </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>29</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Length (Pic : <B>in</B> Picture;<BR>
Currency : <B>in</B> String := Default_Currency)<BR>
<B>return</B> Natural;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>30</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.4em">Length returns
Pic_String(Pic)'Length + Currency_Length_Adjustment - Radix_Adjustment
where </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>31</FONT></DIV>
<UL Class="CodeIndentedBulleted" Style="margin-bottom: 0.3em"><LI TYPE=DISC>Currency_Length_Adjustment = </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>32</FONT></DIV>
<UL Class="CodeIndentedNestedBulleted"><LI TYPE=DISC>Currency'Length - 1 if there is some occurrence of '$'
in Pic_String(Pic), and</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>33</FONT></DIV>
<UL Class="CodeIndentedNestedBulleted"><LI TYPE=DISC>0 otherwise. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>34</FONT></DIV>
<UL Class="CodeIndentedBulleted" Style="margin-bottom: 0.3em"><LI TYPE=DISC>Radix_Adjustment = </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>35</FONT></DIV>
<UL Class="CodeIndentedNestedBulleted"><LI TYPE=DISC>1 if there is an occurrence of 'V' or 'v' in Pic_Str(Pic),
and</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>36</FONT></DIV>
<UL Class="CodeIndentedNestedBulleted" Style="margin-bottom: 0.7em"><LI TYPE=DISC>0 otherwise. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>37</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Valid (Item : <B>in</B> Num;<BR>
Pic : <B>in</B> Picture;<BR>
Currency : <B>in</B> String := Default_Currency)<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>38</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">Valid returns
True if Image(Item, Pic, Currency) does not raise Layout_Error, and returns
False otherwise.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>39</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Image (Item : <B>in</B> Num;<BR>
Pic : <B>in</B> Picture;<BR>
Currency : <B>in</B> String := Default_Currency;<BR>
Fill : <B>in</B> Character := Default_Fill;<BR>
Separator : <B>in</B> Character := Default_Separator;<BR>
Radix_Mark : <B>in</B> Character := Default_Radix_Mark)<BR>
<B>return</B> String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">Image returns
the edited output String as defined in <A HREF="AA-F-3-2.html">F.3.2</A>
for Item, Pic_String(Pic), Blank_When_Zero(Pic), Currency, Fill, Separator,
and Radix_Mark. If these rules identify a layout error, then Image raises
the exception Layout_Error.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>41</FONT></DIV>
<DIV Class="Examples"><TT><B>procedure</B> Put (File : <B>in</B> File_Type;<BR>
Item : <B>in</B> Num;<BR>
Pic : <B>in</B> Picture;<BR>
Currency : <B>in</B> String := Default_Currency;<BR>
Fill : <B>in</B> Character := Default_Fill;<BR>
Separator : <B>in</B> Character := Default_Separator;<BR>
Radix_Mark : <B>in</B> Character := Default_Radix_Mark);<BR>
<BR>
<B>procedure</B> Put (Item : <B>in</B> Num;<BR>
Pic : <B>in</B> Picture;<BR>
Currency : <B>in</B> String := Default_Currency;<BR>
Fill : <B>in</B> Character := Default_Fill;<BR>
Separator : <B>in</B> Character := Default_Separator;<BR>
Radix_Mark : <B>in</B> Character := Default_Radix_Mark);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>42</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">Each of these
Put procedures outputs Image(Item, Pic, Currency, Fill, Separator, Radix_Mark)
consistent with the conventions for Put for other real types in case
of bounded line length (see <A HREF="AA-A-10-6.html">A.10.6</A>, ``<A HREF="AA-A-10-6.html">Get
and Put Procedures</A>'').</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>43</FONT></DIV>
<DIV Class="Examples"><TT><B>procedure</B> Put (To : <B>out</B> String;<BR>
Item : <B>in</B> Num;<BR>
Pic : <B>in</B> Picture;<BR>
Currency : <B>in</B> String := Default_Currency;<BR>
Fill : <B>in</B> Character := Default_Fill;<BR>
Separator : <B>in</B> Character := Default_Separator;<BR>
Radix_Mark : <B>in</B> Character := Default_Radix_Mark);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>44</FONT></DIV>
<DIV Class="CodeIndented">Put copies Image(Item, Pic, Currency, Fill,
Separator, Radix_Mark) to the given string, right justified. Otherwise
unassigned Character values in To are assigned the space character. If
To'Length is less than the length of the string resulting from Image,
then Layout_Error is raised. </DIV>
<H4 ALIGN=CENTER>Implementation Requirements</H4>
<DIV Class="Paranum"><FONT SIZE=-2>45</FONT></DIV>
<DIV Class="Normal"> 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.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>45.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>This implies
that a picture string with character replications need not be supported
(i.e., To_Picture will raise Picture_Error) if its expanded form exceeds
30 characters. </FONT></DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>46</FONT></DIV>
<DIV Class="Notes" Style="margin-bottom: 0.4em"><FONT SIZE=-1>4 The
rules for edited output are based on COBOL (ANSI X3.23:1985, endorsed
by ISO as ISO 1989-1985), with the following differences: </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>47</FONT></DIV>
<UL Class="NotesBulleted"><FONT SIZE=-1><LI TYPE=DISC>The COBOL provisions for picture string localization and
for 'P' format are absent from Ada.</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>48</FONT></DIV>
<UL Class="NotesBulleted" Style="margin-bottom: 0.3em"><FONT SIZE=-1><LI TYPE=DISC>The following Ada facilities are not in COBOL: </LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>49</FONT></DIV>
<UL Class="NotesNestedBulleted"><FONT SIZE=-1><LI TYPE=DISC>currency symbol placement after the number,</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>50</FONT></DIV>
<UL Class="NotesNestedBulleted"><FONT SIZE=-1><LI TYPE=DISC>localization of edited output string for multi-character
currency string values, including support for both length-preserving
and length-expanding currency symbols in picture strings</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>51</FONT></DIV>
<UL Class="NotesNestedBulleted"><FONT SIZE=-1><LI TYPE=DISC>localization of the radix mark, digits separator, and fill
character, and</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>52</FONT></DIV>
<UL Class="NotesNestedBulleted"><FONT SIZE=-1><LI TYPE=DISC>parenthesization of negative values. </LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>52.1</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1><S></S>The value of 30 for Max_Picture_Length
is the same limit as in COBOL. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>52.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>There are several
reasons we have not adopted the COBOL-style permission to provide a single-character
replacement in the picture string for the `$' as currency symbol, or
to interchange the roles of `.' and `,' in picture strings </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>52.b</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>It would have introduced considerable complexity into Ada,
as well as confusion between run-time and compile-time character interpretation,
since picture Strings are dynamically computable in Ada, in contrast
with COBOL</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>52.c</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>Ada's rules for real literals provide a natural interpretation
of `_' as digits separator and `.' for radix mark; it is not essential
to allow these to be localized in picture strings, since Ada does not
allow them to be localized in real literals.</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>52.d</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>The COBOL restriction for the currency symbol in a picture
string to be replaced by a single character currency symbol is a compromise
solution. For general international usage a mechanism is needed to localize
the edited output to be a multi-character currency string. Allowing a
single-Character localization for the picture Character, and a multiple-character
localization for the currency string, would be an unnecessary complication.
</LI></FONT></UL>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-F-3-2.html">Previous</A> <A HREF="AA-F-3-4.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|