The Write command is used to write updated data channel information back to CSV files in the local file system. This is required to preserve data which may have been modified by associated toggle or track touch controls so that user input can be retained for subsequent Lightwing scripts or any other application to use. Data channels can be used strictly to display information with Text and Ticker commands, in which case there is no need to write the data back to the file system. But, when touch controls are associated with a data channel, the channel will be modified when those controls are moved. This allows subsequent pages to access user input, but all data channels are lost when the script ends, unless they are written to the file system.
The Write command always exports data as a two-dimensional array of strings in the CSV (Comma Separated Values) format. Track control values will be in floating-point format, such as “10.123” and toggle controls values will be either “on” or “off”.
The only parameters to this command is a list of data channel names which defines the files that will be written. Data file names are required to have the .csv extension (which is assumed) and reside in the data folder. Only data channels which have actually been modified since the last Write command will be written. This command can be used as often as required, but only once per page and not on the global page.
Example of Touch Controls with an Associated Data Channel Read and Write Back to File // This command opens the data channel and reads its contents from the file system. data: DataFile.csv page: FirstPage time: 0, 0 // This button is required to exit the page. box: ExitButton position: 50, 10 size: 20, 10 toggle: ExitButton jump: ExitPage toggle: ExitButton box: ExitButton text: OpenSansRegular_40 box: ExitButton type: "Exit" // These touch controls allow the user to modify the indexed items in the data channel array. toggle: Button position: 50, 20 size: 40, 20 data: DataFile index: 0, 0 track: Slider axis: X position: 50, 30 size: 80, 20 range: 0, 1 data: DataFile index: 0, 1 // This page writes the modified data channel back to the file system. page: ExitPage write: DataFile