Go to: Synopsis. Return value. Related. MEL examples.

Synopsis

fgetline <int>

fgetline is undoable, queryable, and editable.

Returns the next line (string of characters followed by a newline) or nothing if end of file is reached.

Return value

string

In query mode, return type is based on queried flag.

Related

fclose, feof, fflush, fgetword, fopen, fprint, fread, frewind, fwrite, pclose, popen

MEL examples

// Make a sample file to use as a test example
//
$exampleFileName = ( `internalVar -userTmpDir` + "example.tmp" );
$fileId=`fopen $exampleFileName "w"`;
fprint $fileId "Hello there\nMEL user\n";
fclose $fileId;

// Now read it back one line at a time
//
$fileId=`fopen $exampleFileName "r"`;
string $nextLine = `fgetline $fileId`;
while ( size( $nextLine ) > 0 ) {
    print ( $nextLine );
    $nextLine = `fgetline $fileId`;
}
fclose $fileId;