Skip to content

Commit

Permalink
Added a example for FileIsEOF() function
Browse files Browse the repository at this point in the history
  • Loading branch information
cfmitrah committed Mar 6, 2024
1 parent d731c1a commit 1a34ce2
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion docs/03.reference/01.functions/fileiseof/_examples.md
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
*There are currently no examples for this function.*
```luceescript
filePath = "/path/to/file.txt"
openFile = fileopen(filePath, "read");
lines = [];
// IMPORTANT: must close file, use try/catch/finally to do so
try {
// fileIsEOF(openFile) == false until we've read in the last line.
while( !fileIsEoF(openFile) ) {
arrayAppend(lines, fileReadLine( openFile ));
}
} catch(any e) {
rethrow;
} finally {
fileClose(openFile);
}
```

0 comments on commit 1a34ce2

Please sign in to comment.