DADiSP Worksheet Functions > Function Categories > File Manipulation > FGETS

 

FGETS

Purpose:

Returns the next line from the specified input file.

Syntax:

FGETS("filename")

"filename"

-

A string, the source file name.

Returns:

A string.

Example:

If the file myheader.hdr contains the following:

ASCII data file

Interval 20

then the commands:

 

fopen("myheader.hdr", 'r+')

fgets("myheader.hdr")

fclose("myheader.hdr")

 

display "ASCII data file" at the bottom of the screen before closing the file.

 

fopen("myheader.hdr", 'r+')

str1 = fgets("myheader.hdr")

str2 = fgets("myheader.hdr")

fclose("myheader.hdr")

 

sets the variable str1 to "ASCII data file" and str2 to "Interval 20".

Remarks:

FGETS must be used with FOPEN and FCLOSE. The file name must be in quotes or otherwise in string form. When the file is first opened, FGETS returns the first line. Subsequent calls to FGETS return the line following the line previously returned.

See Also:

FCLOSE

FCLOSEALL

FOPEN

FPUTS