⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fformats.gml

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 GML
📖 第 1 页 / 共 3 页
字号:
and
.id BZ
.ix 'BN edit descriptor'
.ix 'BZ edit descriptor'
.ix 'edit descriptor' BN
.ix 'edit descriptor' BZ
edit descriptors are used to describe the interpretation
of embedded blanks in numeric input fields.
They only effect
.id I,
.id F,
.id E,
.id D
and
.id G
editing and have no effect during output.
When a
.id BN
edit descriptor is encountered in a format specification,
embedded blanks in subsequent numeric input fields are ignored.
However, a field of all blanks has the value of zero.
If a
.id BZ
edit descriptor is encountered, then all embedded blanks
in subsequent numeric input fields are treated as zeroes.
At the beginning of each I/O statement, all blanks are treated as
zeroes or ignored depending on the value of the
.kw BLANK=
specifier
(see the
.kw OPEN
statement) currently in effect for the unit.
.*
.section $ or \ Editing (Extension)
.*
.np
.ix '$ edit descriptor'
.ix '\ edit descriptor'
.ix 'edit descriptor' $
.ix 'edit descriptor' \
.xt begin
The $ and \ edit descriptors behave identically.
The $ and \ edit descriptors are intended for output to an interactive
device such as a terminal.
They are a &product extensions.
The output record is displayed at the terminal leaving the cursor at
the end of the record; the carriage return at the end of the line is
suppressed.
Its use is intended for prompting for input so that the response can
be entered immediately following the prompt.
.xt end
.np
Depending on the type of terminal, the prompt may be returned as part
of the input.
An application must be aware of the way a particular terminal behaves.
The following example demonstrates this.
Note that the format specification in the
.kw FORMAT
statement labelled
.mono 20
ignores the first eleven characters of the
response since the prompt also appears in the response.
.exam begin
      INTEGER AGE
      WRITE(6,FMT=10)
10    FORMAT( 'Enter age: ',$ )
      READ(5,20) AGE
20    FORMAT( 11X, I2 )
      PRINT *,'Your age is ',AGE
      END
.exam end
.pc
If the terminal you are using does not return the prompt as part of the
response (that is, a read from the terminal only includes characters
typed at the terminal), the format specification in the
.kw FORMAT
statement labelled
.mono 20
must be changed, as in the following example, to achieve the same result.
.exam begin
      INTEGER AGE
      WRITE(6,FMT=10)
10    FORMAT( 'Enter age: ',\/ )
      READ(5,20) AGE
20    FORMAT( I2 )
      PRINT *,'Your age is ',AGE
      END
.exam end
.*
.section Numeric Editing: I, F, E, D and G Edit Descriptors
.*
.np
Numeric edit descriptors are used to specify I/O of integer, real,
double precision, complex and double precision complex data.
The following rules apply to all numeric edit descriptors.
.autopoint
.point
On input, leading blanks are not significant.
The interpretation of blanks other than leading blanks is determined
by any
.id BN
or
.id BZ
edit descriptors in effect and the
.kw BLANK=
specifier (see the
.kw OPEN
statement).
A field of all blanks is always zero.
Plus signs are optional.
.point
On input, with
.id F,
.id E,
.id D
and
.id G
editing, the decimal location specified
in the edit descriptor is overridden by a decimal point appearing
in the input field.
.point
On output, the plus sign is optional and is determined by the
.id S,
.id SP
and
.id SS
edit descriptors.
A negative quantity is represented by a negative sign.
A minus sign is never produced when outputting a value of zero.
.point
On output, the representation is always right justified in the field
with leading blanks inserted at the beginning of the field if the
number of characters in the representation is less than the field width.
.point
On output, if the number of characters in the external representation
is greater than the field width or an exponent exceeds its specified
length using
.id Ew.dEe,
.id Gw.dEe,
.id Ew.dDe
or
.id Gw.dDe
edit descriptors, the entire field
is filled with asterisks.
.endpoint
.*
.beglevel
.*
.section Integer Editing: Iw and Iw.m Edit Descriptors
.*
.np
The
.id Iw
and
.id Iw.m
.ix 'I edit descriptor'
.ix 'edit descriptor' numeric I
edit descriptors indicate that the field width
of the field to be edited is
.id w.
The item in the I/O list must be of type integer; on input the
I/O list item will be defined by integer data, on output the I/O
list item must be defined with an integer datum.
.np
On input, the
.id Iw.m
edit descriptor is treated identically to the
.id Iw
edit descriptor.
The output field for the
.id Iw
edit descriptor consists of zero or
more leading blanks followed by a minus sign if the value of the
I/O list item is negative or an optional plus sign otherwise,
followed by the magnitude of the integer datum with no leading zeroes.
Note that the integer constant contains at least one digit.
On output, the
.id Iw.m
edit descriptor specifies that at least
.id m
digits are to be displayed with leading zeroes if necessary.
The value of
.id m
must be less than or equal to the value of
.id w.
If
.id m
is zero and the value of the datum is zero, then the output
field is filled with blanks.
.exam begin
      PRINT '(1H<,I4.4,I5,1H>)',23,2345
.exam end
.pc
The output produced by the
.kw PRINT
statement in the previous example is the string:
.millust begin
<0023 2345>
.millust end
.*
.section Floating-point Editing: F, E, D and G Edit Descriptors
.*
.np
The
.id F,
.id E,
.id D
and
.id G
edit descriptors describe the editing of real,
double precision, complex and double precision complex data.
The I/O list item corresponding to one of these edit descriptors
must be of type real, double precision, complex or double precision
complex.
On input, the I/O list item will become defined with a datum whose
type is the same as that of the I/O list item.
On output, the I/O list item must be defined with a datum whose
type is that of the I/O list item.
.*
.section F Editing
.*
.np
An
.id F
edit descriptor has the form
.ix 'F edit descriptor'
.ix 'edit descriptor' numeric F
.id Fw.d
where
.id w
is the field width and
.id d
is the number of digits in the fractional part.
The input field consists of an optional sign, followed by a string
of digits optionally containing a decimal point.
If the decimal point is omitted, the rightmost
.id d
digits with leading zeroes assumed if necessary, are interpreted as
the fractional part of the value represented.
An exponent of one of the following forms may follow.
.autopoint
.point
A signed integer constant.
.point
An
.id E
or
.id D
followed by an optionally signed integer constant.
.endpoint
.np
Consider the following example, where the decimal point is omitted.
The formula used in the evaluation is:
.millust begin
                       -d      (exponent subfield)
(integer subfield) x 10    x 10
.millust end
.pc
If the specification is F10.8 and the input quantity is 31415E+5
then the following conversion takes place.
.millust begin
                   -8      5
      00031415 x 10    x 10

                   5
=   .00031415 x 10

=   31.415
.millust end
.pc
In other words, the decimal point is assumed to lie to the left of the
8 digits (padded with zeroes on the left) forming the fractional part
of the input value.
.np
The output field produced by an
.id F
edit descriptor consists of blanks
if necessary followed by a minus sign if the item in the I/O list
is negative or an optional plus sign otherwise, followed by
a string of digits containing a decimal point which represents the
magnitude of the I/O list item.
The string representing the magnitude of the I/O list item is
modified according to the scale factor and is rounded to
.id d
fractional digits.
An optional leading zero is produced only if the magnitude of the I/O
list item is less than one.
Note that a leading zero is required if there would otherwise be no
digits in the output field.
.exam begin
      PRINT '(1H<,F8.4,1H>)', 234.43
.exam end
.pc
The output produced by the
.kw PRINT
statement in the previous example is the string:
.millust begin
<234.4300>
.millust end
.*
.section E and D Editing
.*
.np
The
.id Ew.d,
.id Dw.d
and
.id Ew.dEe
edit descriptors indicate that the field
.ix 'E edit descriptor'
.ix 'edit descriptor' numeric E
.ix 'D edit descriptor'
.ix 'edit descriptor' numeric D
width is
.id w,
the fractional part contains
.id d
digits unless a scale
factor greater than one is in effect, and the exponent consists of
.id e
digits.
The
.id e
has no effect on input.
.np
The form of the input field and processing of it is the same as that
for
.id F
editing.
The form of the output field is:
.mbox begin
      [+] [0] . x  x  ... x  exp
      [-]        1  2      d
.mbox end
.synote
.mnote ~p
indicates a plus or minus sign.
.mnote x's
are the
.id d
most significant digits of the value after rounding.
.mnote exp
is a decimal exponent.
.endnote
.np
The form of the exponent is as follows.
.autopoint
.point
When using the
.id Ew.d
edit descriptor, the form of the exponent is
.millust begin
E+nn
 or       if |exp| <= 99
E-nn
.millust end
.pc
and
.millust begin
+nnn
 or       if 99 < |exp| <= 999
-nnn
.millust end
.pc
.point
When using the
.id Ew.dEe
edit descriptor, the form of the exponent is
.millust begin
E+n ... n   where |exp| <= (10**e)-1
 - 1     e
.millust end
.point
When using the
.id Dw.d
edit descriptor, the form of the exponent is
.millust begin
D+nn
 or       if |exp| <= 99
D-nn
.millust end
.pc
and
.millust begin
+nnn
 or       if 99 < |exp| <= 999
-nnn
.millust end
.endpoint
.np
Note that a sign in the exponent is always present.
If the exponent is 0, a plus sign is used.
The forms
.id Ew.d
and
.id Dw.d
are not to be used if
.mono |exp| > 999.
.np
.exam begin
      PRINT '(1H<,E10.4,1H>,1H<,E9.4,1H>,1H<,E12.4E3,1H>)',
     $      .5, .5, .5
      END
.exam end
.pc
The output from the
.kw PRINT
statement in the previous example is the string:
.millust begin
<0.5000E+00><.5000E+00>< 0.5000E+000>
.millust end
.np
The scale factor
.id k
in a
.id P
edit descriptor controls decimal normalization
as follows:
.autopoint
.point
If
.mono -d < k <= 0,
then the output field contains
.id |k|
leading zeroes and
.id d-|k|
significant digits after the decimal point.
.point
If
.mono 0 < k < d+2,
the output field contains exactly
.id k
significant digits to the left of the decimal point and
.id d-k+1
significant digits to the right of the decimal point.
.point
Other values of
.id k
are not permitted.
.endpoint
.np
.xt begin
The
.id Ew.dDe
edit descriptor behaves in the same way as the
.id Ew.dEe
edit descriptor on input; on output the only difference is that the
letter
.id D
is used to mark the exponent instead of the letter
.id E.
.xt end
.*
.section *refid=gedit G Editing
.*
.np
The
.id Gw.d
and
.id Gw.dEe
edit descriptors indicate that the field
.ix 'D edit descriptor'
.ix 'edit descriptor' numeric D
width is
.id w,
the fractional part contains
.id d
digits unless a scale
factor greater than one is in effect, and the exponent consists of
.id e
digits.
.np
.id G
input editing is the same as
.id F
input editing.
.np
The representation on
.id G
output editing depends on the magnitude of the
datum being edited.
Let
.id M
be the magnitude of the datum being edited.
Then
.id G
output editing behaves as follows.
.autopoint
.point
If
.mono M < 0.1
or
.mono M >= 10**d,
.id Gw.d
output editing is equivalent to
.id kPEw.d
output editing and
.id Gw.dEe
output editing is equivalent to
.id kPEw.dEe
output editing where
.id k
is the scaling factor currently in effect.
.point
If
.mono 0.1 <= M < 10**d,
the scale factor has no effect and the value of
.id M
determines the editing as shown in the following table.
.endpoint
.if &e'&dohelp eq 0 .do begin
.cp 15
.* .box on 1 19 45
.sr c0=&INDlvl+1
.sr c1=&INDlvl+19
.sr c2=&INDlvl+45
.box on &c0 &c1 &c2
\Magnitude of Datum    \Equivalent Edit Descriptor\
.box
\0.1<=M<1              \F<w-n>.d followed by n blanks\
\1<=M<10               \F<w-n>.<d-1> followed by n blanks\
\    .                 \           .\
\    .                 \           .\
\    .                 \           .\
\10**(d-2)<=M<10**(d-1)\F<w-n>.1 followed by n blanks\
\10**(d-1)<=M<10**d    \F<w-n>.0 followed by n blanks\
.box off
.do end
.el .do begin
.millust begin
+-----------------------+-----------------------------------+
| Magnitude of Datum    | Equivalent Edit Descriptor        |
+-----------------------+-----------------------------------+
| 0.1<=M<1              | F<w-n>.d followed by n blanks     |
| 1<=M<10               | F<w-n>.<d-1> followed by n blanks |
|     .                 |            .                      |
|     .                 |            .                      |
|     .                 |            .                      |
| 10**(d-2)<=M<10**(d-1)| F<w-n>.1 followed by n blanks     |
| 10**(d-1)<=M<10**d    | F<w-n>.0 followed by n blanks     |
+-----------------------+-----------------------------------+
.millust end
.do end
.synote 8
.mnote <w-n>
stands for the integer represented by evaluating
.id w-n.
.mnote <d-1>
stands for the integer represented by evaluating
.id d-1.
.mnote n
is 4 for
.id Gw.d
editing and
.id e+2
for
.id Gw.dEe
editing.
.endnote
.exam begin
      PRINT '(1H<,G12.6,1H>,1H<,G12.4E4,1H>)', .5, .5
      END
.exam end
.pc
The output from the
.kw PRINT
statement in the previous example is the string:
.millust begin
<0.500000    ><0.5000      >
.millust end
.*
.section Complex Editing
.*
.np
Since a complex datum consists of a pair of real or double precision
data, the editing
.ix 'complex edit descriptor'
.ix 'edit descriptor' numeric complex
of a complex datum is specified by two successive pairs of
.id F,
.id E,
.id D
or
.id G
edit descriptors.
The two descriptors may be different and may be separated by any number
of non-repeatable edit descriptors.
.xt on
Double precision complex editing is identical to complex editing.
.xt off
.endlevel
.*
.section L Edit Descriptor
.*
.np
The
.id Lw
.ix 'L edit descriptor'
.ix 'edit descriptor' L
edit descriptor is used for I/O list items of type logical.
The field width is
.id w.
.np
On input the I/O list item will become defined with a datum of
type logical.
The input field consists of optional blanks, followed by an optional
decimal point followed by a
.mono T
or
.mono F

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -