Skip to main content

WriteFile

This function was added in DSL 4

Description

Write data to file.

function WriteFile(file, data) --[[ ... ]] end

Parameters

  • file: userdata - The file handle to write to. This should be the same handle returned by OpenFile.
  • data: string - The data to write to the file. This can be any string, including binary data.

Return Values

None.

Example

local file = OpenFile('output.txt', 'w')
if file then
-- highligh-next-line
WriteFile(file, 'Hello, world!') -- Write data to the file
CloseFile(file)
else
print('Failed to open file')
end

See Also