# OpenToWrite

## Description

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. 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.

## Definition

OpenToWrite( ID, szFile )

void agk::OpenToWrite( UINT ID, const char *szFile )

integer OpenToWrite( szFile, append )

UINT agk::OpenToWrite( const char *szFile, int append )

integer OpenToWrite( szFile )

UINT agk::OpenToWrite( const char *szFile )

OpenToWrite( ID, szFile, append )

void agk::OpenToWrite( UINT ID, const char *szFile, int append )

## Parameters

- ID - The ID to use to reference this file later.
- szFile - The filename to open for writing.
- append - Set to 1 to append to the file, 0 to overwrite all data (optional, default 0).