hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_file_line_read (x04bb)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_file_line_read (x04bb) reads a single formatted record from an external file.

Syntax

[recin, ifail] = x04bb(nin, reclen)
[recin, ifail] = nag_file_line_read(nin, reclen)

Description

nag_file_line_read (x04bb) is used by NAG Library functions to read formatted records from an external file. All formatted input from an external file by NAG Library functions is performed by calls to nag_file_line_read (x04bb).

References

None.

Parameters

Compulsory Input Parameters

1:     nin int64int32nag_int scalar
The Fortran unit number which identifies the file to be read from. If nin<0 (not a valid Fortran unit number), then no input occurs.
2:     reclen int64int32nag_int scalar
The maximum length of the record in characters.

Optional Input Parameters

None.

Output Parameters

1:     recin – string
The first LEN(recin) characters of the record read from unit nin, padded with trailing blanks if the record was shorter than LEN(recin).
2:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
An end-of-file was detected by the READ statement.
System-dependent errors may also occur if the unit specified by nin is not connected to an external file, or if a read error occurs.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

Not applicable.

Further Comments

None.

Example

This example program simply illustrates how a formatted record is read from the NAG Toolbox, by first reading it into the character-string recin, used as an internal file, by nag_file_line_read (x04bb) and then reading the internal file.
function x04bb_example


fprintf('x04bb example results\n\n');

% Filename and asociated unit number
file   = 'foo.data';
iounit = int64(4);

% Open file for writing
mode    = int64(1);
[ifail] = x04ac(iounit, file, mode);

% Write line to file
x04ba(iounit, ' 20  2.996');

% Close file
[ifail] = x04ad(iounit);

% Reopen file for reading
mode    = int64(0);
[ifail] = x04ac(iounit, file, mode);

% Read line from file
reclin = int64(40);
[recin, ifail] = x04bb(iounit, reclin);

disp(recin);

% reclose file
[ifail] = x04ad(iounit);

delete(file)


x04bb example results

 20  2.996                              

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015