Official ZPE/YASS documentationSequentialFile object
ZPE 1.6.7 (November 2018) added the SequentialFile 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.
SequentialFile object functions
The following is a list of internal functions the SequentialFile 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.
$f = new SequentialFile() $f->open("list.txt") while ($f->has_next()) print($f->read_line()) end while
The file_open_sequentially function
Before its removal in version 1.7.5, the built-in
file_open_sequentially function generated a new
SequentialFile object. This can be stored in a
variable and referenced later using the object syntaxes.