2,732
edits
Red Leader (talk | contribs) (→readln(): Typo) |
Red Leader (talk | contribs) (→write(): Finish doc) |
||
Line 355: | Line 355: | ||
|param2 = string | |param2 = string | ||
|param2text = String to write to the file. | |param2text = String to write to the file. | ||
|example1 = | {{tip|It is good practice to make sure that all lines, including the last one, end in a newline (<code>\n</code>). This will especially help if you will be calling {{func link|readln()}} on the file later.}} | ||
|example1 = var path = getprop("/sim/fg-home") ~ '/Export/demo.txt'; | |||
var file = io.open(path, "wb"); # open in write mode | |||
var str = 'Hello World!' ~ "\n"; | |||
io.write(file, str); # write the data | |||
io.close(file); # close (and flush) the file stream | |||
}} | }} | ||