Difference between revisions of "Readline"

From Mesham
Jump to navigationJump to search
(Created page with '== Overview == This readline[n] function will read a line from a file with handle ''n''. The file handle maintains its position in the file, so after a call to readline the posi…')
 
Line 1: Line 1:
 
== Overview ==
 
== Overview ==
  
This readline[n] function will read a line from a file with handle ''n''. The file handle maintains its position in the file, so after a call to readline the position pointer will be incremented.  
+
This readline(f) function will read a line (delimited by the new line character) from a file with handle ''f''. The file handle maintains its position in the file, so after a call to readline the position pointer will be incremented.  
  
* '''Pass:''' The file handle to read the line from
+
* '''Pass:''' The [[File]] handle to read the line from
* '''Returns:''' A line of the file type String
+
* '''Returns:''' A line of the file type [[String]]
  
 
== Example ==
 
== Example ==
  
  var a:=openfile["hello.txt","r"];
+
#include <io>
  var u:=readline[a];
+
  var f:=open("hello.txt","r");
  closefile[a];  
+
  var u:=readline(f);
 +
  close(f);
  
 
[[Category:Function Library]]
 
[[Category:Function Library]]
 
[[Category:IO Functions]]
 
[[Category:IO Functions]]

Revision as of 13:12, 13 January 2013

Overview

This readline(f) function will read a line (delimited by the new line character) from a file with handle f. The file handle maintains its position in the file, so after a call to readline the position pointer will be incremented.

  • Pass: The File handle to read the line from
  • Returns: A line of the file type String

Example

#include <io>
var f:=open("hello.txt","r");
var u:=readline(f);
close(f);