Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Wabbitseason | |
Old Version | Published before Godot 3 was released. |
I’m new to Godot and wish to parse a file by characters. The file can be quite large so I’d prefer not reading the whole thing as a string. So far I have this:
var file = File.new()
file.open(filename, File.READ)
while !file.eof_reached():
var character = char(file.get_8())
if !file.eof_reached():
print(character) # here I would call my parser
Without the if
inside the while
the last character is always garbage since the EOF is only reached after executing file.get_8()
. As far as I know there is no do while
loop in GDscript, so is there a better way to achieve this?