Files
This AeroScript program opens, reads, writes, and removes files, and does some other basic file functions. The files that you access will be on the controller file system. See Controller File System for more information.
// Files Example: // Demonstrates writing and reading a simple text file on the controller file system. // program var $fileHandle as handle var $valuesToWrite[] as real = [1.1, 2.2, 3.3, 4.4, 5.5] // Open a file for overwriting. If the file already exists, the contents of // the file will be overwritten. $fileHandle = FileOpenText("TemporaryFile.txt", FileMode.Overwrite) // Write 5 numerical values to the file, each on a separate line. foreach var $value in $valuesToWrite FileTextWriteString($fileHandle, RealToString($value) + "\n") end // Close the file. FileClose($fileHandle) // Open the file for reading. $fileHandle = FileOpenText("TemporaryFile.txt", FileMode.Read) // Read all lines from the files in a loop. AppMessageDisplay("Displaying lines in the file:") while (true) var $stringValue as string // Read the next line. $stringValue = FileTextReadLine($fileHandle) if (StringEquals($stringValue, "")) break end // Display the line that was read. AppMessageDisplay($stringValue) Dwell(0.100) end // Close the file. FileClose($fileHandle) end