VF_nreadVD_nreadVE_nread
VCF_nreadVCD_nreadVCE_nread
VPF_nreadVPD_nreadVPE_nread
VI_nreadVBI_nreadVSI_nreadVLI_nreadVQI_nread 
VU_nreadVUB_nreadVUS_nreadVUL_nreadVUQ_nreadVUI_nread
FunctionRead the columns of a table from a stream
Syntax C/C++#include <VFstd.h>
void VF_nread( unsigned n, ui size, FILE *stream, ... );
Pascal/Delphiuses VFstd;
procedure VF_nread( VecList:^fVector; n:Word; size:UIntSize; var stream:Text );
Description C/C++n columns of a table are read into the vectors passed to VF_nread. The number of lines is specified as the number of elements of each vector, which is size.

The entries of each line should be separated by spaces (' ') or tab characters ('\t').

Each line must be terminated by a line-feed character ('\n'). The length of the lines is limited according the following rules:
- Either all lines have the same length. In this case, the length is determined automatically and might in principle be as large as 65535 characters.
- Or the maximum length is given by the number n of vectors to be read and by the data type:
 
VF_ 24*n
VBI_,   VUB_13*n
VD_ 32*n
VSI_,   VUS_21*n
VE_ 40*n
VLI_,   VUL_37*n
VCF_,   VPF_ 48*n
VQI_,   VUQ_32*n
VCD_,   VPD_ 64*n
VI_,   VU_as VLI_,   VUL_
VCE_,   VPE_ 80*n
 

It is possible to read fewer vectors than there are columns in a table. In this case, the trailing columns are neglected. If, however, you try to read more vectors than there are columns, the result is undefined and might lead to an error.

Complex versions (both cartesian and polar):
Real und imaginary (or Mag and Arg) parts may, but need not, be enclosed in braces { }. However, you must be consequent: Either all or no element may be written with braces.

Whole-number versions except VQI_nread:
By default, the numbers to be read are interpreted as decimal numbers. You may use V_setRadix to define any radix between 2 and 36.

Example C/C++VF_nread( 3, 100, DataFile, X, Y, Z );
 
GCC Windows specific:In principle, the Windows port of GCC supports the 80-bit floating point type long double. However, the I/O routines rely on the runtime libraries of Visual C++, where 80-bit reals have disappeared a long time ago. This means that VE_nread, VCE_nread, and VPE_nread work only with double precision and, more importantly, within double range. Input numbers outside double range are treated as ±DBL_MAX.
 
Description Pascal/Delphin columns of a table are read into the vectors passed as the list VecList to VF_nread. The number of lines is specified as the number of elements of each vector, which is size.

The entries of each line should be separated by spaces (' ') or tab characters (#9). Other separators are not allowed. Each line must be terminated by a line-feed character (#13).

It is possible to read fewer vectors than there are columns in a table. In this case, the trailing columns are neglected. If, however, you try to read more vectors than there are columns, the result is undefined and might lead to an error.

Complex versions (both cartesian and polar):
Real und imaginary (or Mag and Arg) parts may (but need not) be enclosed in braces { }. However, you must be consequent: Either all or no element may be written with braces.

Whereas the C version of these functions follows the conventions of the C functions strtod,   strtol, etc., the Pascal version has to follow the rules applying to the Pascal function Read. This makes the Pascal version much less flexible than the C version:
- no separation characters allowed other than ' ' and #9,
- no automatic truncation of overflowing numbers,
- no function V_setRadix

Example Pascal/Delphivar MyFile: Text;
    X, Y1, Y2: fVector;
    VList: array[0..2] of fVector;
begin
    X := VF_vector( 100 );
    Y1 := VF_vector( 100 );
    Y2 := VF_vector( 100 );
    VList[0] := X; VList[1] := Y1; VList[2] := Y2;
    Assign( MyFile, 'Myfile.DAT' );
    Reset( MyFile );
    VF_nread( @VList, 3, 100, MyFile );
    ...
end;
Error handlingC/C++:
Real, complex and quad versions:
Overflowing numbers are silently truncated to ±HUGE_VAL.
Whole-number versions except VQI_nread:
As long as the numbers can be represented as long or unsigned long, overflowing bits are ignored in the 16-bit versions.
Numbers beyond the long range yield −1 (signed types) or +HUGE_VAL (unsigned types).
Pascal/Delphi:
Overflowing numbers or numbers otherwise not conforming to the format requirements lead to an I/O error.
Return valuenone
See alsoVF_nwrite,   VF_read,   VF_store,   VF_recall, strtod,  strtol (C/C++ only)

VectorLib Table of Contents  OptiVec home