To use this website fully, you first need to accept the use of cookies. By agreeing to the use of cookies you consent to the use of functional cookies. For more information read this page.

Official ZPE Programming Environment documentationSequential file object

Introduction

ZPE 1.6.7 (November 2018) added the sequential file object, a built-in object that allows manipulation of files line by line or character by character.

This new object is fast when it comes to reading line by line or character by character and it exposes to certain functionalities.

ZPESequentialFile object functions

The following is a list of internal functions the ZPESequentialFile object exposes. All functions are ZPEObjectNativeFunctions unless specified therefore run in native code.

has_next () ⇒ boolean
Determines if there is another line or character in the sequence.
read_line () ⇒ string
Reads the next line in the sequence.
open (string file) ⇒ boolean
Opens a new file. Added in version 1.7.5.
get_current () ⇒ string
Returns the current string within the buffer. Added in version 1.7.6.

Examples in action

The following example reads some text file line by line.

YASS
$f = file_open_sequentially("list.txt")

while ($f->has_next())
  print($f->read_line())
end while
    

The file_open_sequentially function

Before version 1.7.5, the built-in file_open_sequentially function generated a new ZPESequentialFile object. This can be stored in a variable and referenced later using the object syntaxes.

Comments

There are no comments on this page.

New comment
Reply
Provide feedback on this page
Comments are sent via email to me.