Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | avencherus |
Been puzzling over this for an hour, but using store_line(some_string)
or even store_string(some_string)
produces a file that has no line breaks. They appear in some programs, but in notepad they do not.
More importantly I’m trying to output scripts for command line, and these won’t work as .bat files. The lines will all get executed as one line.
Any suggestions on how to coax the output file into having carriage returns?
A basic code example would look like this:
var output = []
output.append("line 1")
output.append("line 2")
output.append("line 3")
var file = File.new()
if(file.open("res://script.bat", File.WRITE) == OK):
for line in output: file.store_line(line)
file.close()
Results end up like: line 1line 2line 3
Have you tried store_string()
?
Alternatively, you could try write new line directly for each line:
file.store_line('\n') # append new line
, not sure whether that would work…
Xrayez | 2018-07-11 18:25
store_line(line + "\r")
seems to work.
avencherus | 2018-07-11 20:45