forlang.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
WRITE
                                             Up Contents Index Back
─────WRITE──────────────────────────────────────────────────────────────────
 
     Action
 
     Transfers data into a file.
 
     Syntax
 
     WRITE ([UNIT=] unitspec
     [ , [{[ FMT=] formatspec] |[ NML=] nmlspec} ]]
     [ , ERR=errlabel]
     [ , IOSTAT=iocheck]
     [ , REC=rec] )
     iolist
 
     If UNIT= is omitted, <unitspec> must be the first parameter. If
     FMT= or NML= is omitted, <fmtspec> or <nmlspec> must be the
     second parameter. The parameters can otherwise appear in any
     order.
 
     Parameter          Description
 
     unitspec           The unit to read from.
 
                        For an external file, <unitspec> is an integer
                        expression. For an internal file, <unitspec>
                        is a string.
 
                        Calling READ with a unit not explicitly
                        associated with a file causes an implicit open.
 
     formatspec         A format specifier. It can be the label of a
                        FORMAT statement, or the format specification
                        itself.
 
                        <formatspec> is required for a formatted read,
                        and must not appear in an unformatted read.
 
     nmlspec            A group name declared in a NAMELIST statement.
                        If given, <iolist> must be omitted. Available
                        only for sequential access.
 
     errlabel           The label of an executable statement in the
                        same program unit. An I/O error causes transfer
                        of control to the statement at <errlabel>. If
                        <errlabel> is omitted, the effect of an I/O
                        error is determined by the presence or absence
                        of <iocheck>.
 
     iocheck            An integer variable that is set to zero if
                        there is no error, -1 if end-of-file is
                        encountered, or the error number if an error
                        occurs.
 
     rec                Record number to read (direct access files only).
 
     iolist             Variables to receive values read from the file,
                        separated by commas. <Iolist> cannot contain
                        structure variables, but will accept structure
                        elements.
 
     Remarks
 
     If you write to a sequential file, you delete any records that
     exist beyond the newly written record.
 
     If a parameter of the WRITE statement is an expression that calls
     a function, that function must not execute an I/O statement or
     the EOF intrinsic function. Calling these functions can cause
     unpredictable results.
 
     Example
 
     C     Generate a table of square and cube roots
     C     of the whole numbers from 1-100
           WRITE (*, 10) (n, SQRT(FLOAT(n)), FLOAT(n)**(1.0/3.0),
          +       n = 1, 100)
           10 FORMAT (I5, F8.4, F8.5)
                                    -♦-