Opens a file stored on the local filesystem for writing into the specified ID. All platforms are restricted to a single folder for writing so file paths must be relative, not absolute. This write folder is not the same folder as the application itself, so images, sounds, and the application itself cannot be overwritten. Files written to this folder can be read using OpenToRead. If the file does not exist it will be created, if the file does exist it will be overwritten if append is 0. or appended to if append is 1. If a directory is given in the filename and does not exist it will be created.
To write a file outside the normal write folder you can use "raw:" followed by an absolute path for the current platform, for example "raw:C:\MyFolder\MyFile.txt" on Windows or "raw:/sdcard/Documents/MyFile.txt" on Android. If any folders in your chosen path do not exist they will be created.
On Raspberry Pi you can use this command to open a GPIO pin for writing by using the filename "gpio:" followed by the GPIO pin number, for example OpenToWrite(1, "gpio:4"), this is case sensitive. You can then use WriteByte to write 0 or 1 to the pin and CloseFile to close the pin.
OpenToWrite( ID, szFile )
integer OpenToWrite( szFile, append )
integer OpenToWrite( szFile )
OpenToWrite( ID, szFile, append )