File: AA-A-10.html

package info (click to toggle)
ada-reference-manual 20021112web-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, sarge
  • size: 18,652 kB
  • ctags: 8,921
  • sloc: makefile: 52; sh: 20
file content (184 lines) | stat: -rw-r--r-- 14,386 bytes parent folder | download
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
    <TITLE>AARM95 - Text Input-Output</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>&nbsp;&nbsp;&nbsp;<A HREF="AA-0-29.html">Index</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-A-9.html">Previous</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-A-10-1.html">Next</A></P>
<HR>
<H1> A.10 Text Input-Output</H1>

<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;This clause describes the package Text_IO, which
provides facilities for input and output in human-readable form. Each
file is read or written sequentially, as a sequence of characters grouped
into lines, and as a sequence of lines grouped into pages. The specification
of the package is given below in subclause <A HREF="AA-A-10-1.html">A.10.1</A>.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;The facilities for file management given above,
in subclauses <A HREF="AA-A-8-2.html">A.8.2</A> and <A HREF="AA-A-8-3.html">A.8.3</A>,
are available for text input-output. In place of Read and Write, however,
there are procedures Get and Put that input values of suitable types
from text files, and output values to them. These values are provided
to the Put procedures, and returned by the Get procedures, in a parameter
Item. Several overloaded procedures of these names exist, for different
types of Item. These Get procedures analyze the input sequences of characters
based on lexical elements (see Section 2) and return the corresponding
values; the Put procedures output the given values as appropriate lexical
elements. Procedures Get and Put are also available that input and output
individual characters treated as character values rather than as lexical
elements. Related to character input are procedures to look ahead at
the next character without reading it, and to read a character ``immediately''
without waiting for an end-of-line to signal availability.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;In addition to the procedures Get and Put for
numeric and enumeration types of Item that operate on text files, analogous
procedures are provided that read from and write to a parameter of type
String. These procedures perform the same analysis and composition of
character sequences as their counterparts which have a file parameter.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;For all Get and Put procedures that operate on
text files, and for many other subprograms, there are forms with and
without a file parameter. Each such Get procedure operates on an input
file, and each such Put procedure operates on an output file. If no file
is specified, a default input file or a default output file is used.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I5857"></A><A NAME="I5858"></A>At the
beginning of program execution the default input and output files are
the so-called standard input file and standard output file. These files
are open, have respectively the current modes In_File and Out_File, and
are associated with two implementation-defined external files. Procedures
are provided to change the current default input file and the current
default output file. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation defined: </B>external
files for standard input, standard output, and standard error</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5.a.1/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation Note: </B>{<I><A HREF="defect2.html#8652/0113">8652/0113</A></I>}
<U>The default input file and default output file are not the names of
distinct file objects, but rather the <I>role</I> played by one or more
(other) file object(s). Thus, they generally will be implemented as accesses
to another file object. An implementation that implements them by copying
them is incorrect.</U> </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I5859"></A>At the beginning of program
execution a default file for program-dependent error-related text output
is the so-called standard error file. This file is open, has the current
mode Out_File, and is associated with an implementation-defined external
file. A procedure is provided to change the current default error file.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I5860"></A><A NAME="I5861"></A><A NAME="I5862"></A>From
a logical point of view, a text file is a sequence of pages, a page is
a sequence of lines, and a line is a sequence of characters; the end
of a line is marked by a <I>line terminator</I>; the end of a page is
marked by the combination of a line terminator immediately followed by
a <I>page terminator</I>; and the end of a file is marked by the combination
of a line terminator immediately followed by a page terminator and then
a <I>file terminator</I>. Terminators are generated during output; either
by calls of procedures provided expressly for that purpose; or implicitly
as part of other operations, for example, when a bounded line length,
a bounded page length, or both, have been specified for a file.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;The actual nature of terminators is not defined
by the language and hence depends on the implementation. Although terminators
are recognized or generated by certain of the procedures that follow,
they are not necessarily implemented as characters or as sequences of
characters. Whether they are characters (and if so which ones) in any
particular implementation need not concern a user who neither explicitly
outputs nor explicitly inputs control characters. The effect of input
(Get) or output (Put) of control characters (other than horizontal tabulation)
is not specified by the language. <A NAME="I5863"></A></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I5864"></A><A NAME="I5865"></A><A NAME="I5866"></A><A NAME="I5867"></A>The
characters of a line are numbered, starting from one; the number of a
character is called its <I>column number</I>. For a line terminator,
a column number is also defined: it is one more than the number of characters
in the line. The lines of a page, and the pages of a file, are similarly
numbered. The current column number is the column number of the next
character or line terminator to be transferred. The current line number
is the number of the current line. The current page number is the number
of the current page. These numbers are values of the subtype Positive_Count
of the type Count (by convention, the value zero of the type Count is
used to indicate special conditions). </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Examples" Style="margin-bottom: 0.9em"><TT><B>type</B>&nbsp;Count&nbsp;<B>is</B>&nbsp;<B>range</B>&nbsp;0&nbsp;..&nbsp;<I>implementation-defined</I>;<BR>
<B>subtype</B>&nbsp;Positive_Count&nbsp;<B>is</B>&nbsp;Count&nbsp;<B>range</B>&nbsp;1&nbsp;..&nbsp;Count'Last;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;<A NAME="I5868"></A><A NAME="I5869"></A>For an
output file or an append file, a <I>maximum line length</I> can be specified
and a <I>maximum page length</I> can be specified. If a value to be output
cannot fit on the current line, for a specified maximum line length,
then a new line is automatically started before the value is output;
if, further, this new line cannot fit on the current page, for a specified
maximum page length, then a new page is automatically started before
the value is output. Functions are provided to determine the maximum
line length and the maximum page length. When a file is opened with mode
Out_File or Append_File, both values are zero: by convention, this means
that the line lengths and page lengths are unbounded. (Consequently,
output consists of a single line if the subprograms for explicit control
of line and page structure are not used.) The constant Unbounded is provided
for this purpose. </DIV>

<H4 ALIGN=CENTER>Extensions to Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>11.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><A NAME="I5870"></A>Append_File
is new in Ada 95. </FONT></DIV>

<HR>
<P><A HREF="AA-TOC.html">Contents</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-0-29.html">Index</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-A-9.html">Previous</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-A-10-1.html">Next</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>