Go to: Return value. Related commands. Examples.

Synopsis

fgetline <int>

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

Return value

string

Related commands

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

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;