Pow file line

From PlainOldWebserver

Jump to: navigation, search

[edit] Pow_file_line( filehandle )

Returns the next line from a filestream. This function does not recognize trailing newlines in a file, so empty lines at the end of the file will be truncated.

  <pre>
  <?sjs
    var lines = "This is a file\nIt has a nice ending";
  pow_file_put_contents("test.txt",lines,"w");
  var fh = pow_file_open("test.txt","r");   var line = "";   var count = 0;   while(line = pow_file_line(fh)) {      document.write(++count + ": " + line);   }   pow_file_close(fh);  ?> </pre>

Result:

  1: This is a file
  2: It has a nice ending

Personal tools
Navigation