Onetastic Macro Documentation >
>
>
FileSystem_WriteToFile FileSystem_WriteToFile
Writes contents to the given file in either binary or text mode. If the file does not exist, it is created. If it exists, its contents are replaced with the given content. Returns true if contents were written successfully.
Syntax
Bool FileSystem_WriteToFile(
File|String file,
Binary|String data,
String mode)
Parameters
- File|String file
- File to write to. This can either be a File object or a String that contains the full path to the file.
- Binary|String data
- The data to write to the file.
- String mode
- Write mode that indicates binary or the text encoding of the file. Possible values are: binary, utf8, utf16.
RemarksSee below for the how the file is written based on "data" and "mode" parameters:
Type of data |
Value of mode |
Data is written as |
Binary |
binary, utf8, utf16 |
binary |
String |
binary, utf8 |
UTF-8 |
utf16 |
UTF-16 |
Any other type for "mode" parameter is converted to String while calling the function.
Examples
$file = FileSystem_ShowSaveFileDialog("file.txt")
if (IsObject($file))
FileSystem_WriteToFile($file, GetCurrentPage().outlines[0].text, "utf8")
$image = GetCurrentPage().images[0]
$types["Image files"] = "*." & $image.format
$file = FileSystem_ShowSaveFileDialog("image." & $image.format)
if (IsObject($file))
FileSystem_WriteToFile($file, $image.data, "binary")
|