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)


    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example


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


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


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).




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


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:
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.
An unexpected error has been triggered by this routine. Please contact NAG.
Your licence key may have expired or may not have been installed correctly.
Dynamic memory allocation failed.


Not applicable.

Further Comments



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);


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


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