Files

Top  Previous  Next

FreeFlyer provides a variety of interfaces for interacting with external files. For information on working with JSON data, please see the JSON-Formatted Data page.

 

 

FreeFlyer Data Files


For information on FreeFlyer Data Files and Formats, including Ephemeris Files, see the Data Files reference in the Appendix. See also Working with Ephemerides.

 

 

Creating External Object Files


For information on saving the state of a FreeFlyer object to an external file, see the Put command. See the Get command for information on retrieving states from a file. The Object.PutToFile(), Object.PutToString(), Object.GetFromFile(), and Object.GetFromString() methods can also be used in place of the Put and Get commands.

 

Note: The Save and Restore commands provide similar functionality to the Put and Get commands, while saving object data to internal memory instead of external files.

 

 

Determining Information about External Files and Directories


The FileSystem object can be used to gather information about files and directories, such as whether a file exists in a directory or when a file was last modified. The FileSystem object cannot be created and is only accessible via FreeForm script.

 

This example shows how the FileSystem object can be used to create a copy of a file:

 

 

The FileSystem object can be used to delete a file:

 

 

The FileSystem object can be used to create a directory:

 

 

The FileSystem object can be used to move and rename a file:

 

 

Reading Arbitrary File Formats


Two mechanisms are available to open and parse input files. The first mechanism is the simple StringArray.ReadFromFile method. The second mechanism is the more generic and more functional FileInterface object.

 

Using these functionalities, you can:

1.Examine iput and output files.

2.Read arbitrary ephemeris file formats.

3.Integrate into other systems by reading their relative formats.

 

To help parse data out of each line read, review the StringTokenizer object and the String.Split method. See Parsing Arbitrary String Data for more information.

 

Note: The StringArray and FileInterface objects also support the creation of arbitrarily formatted output files. Refer to StringArray.WriteToFile, FileInterface.WriteMode, and FileInterface.Write to get started.

 

Example 1: StringArray ReadFromFile Method

The StringArray.ReadFromFile method is a convenient way to read small ASCII files without having to worry about the details of the format of the file. In this example, a data file is read into a StringArray called fileContents, and then each line is parsed into individual data elements in the lineContents StringArray.

 

Input File: myFile.txt

 

 

Mission Plan

 

 

Output Report

 

lineContents[0]

lineContents[1]

7088.4366419

0.0000000

7088.1359928

2.0000000

7087.8048512

4.0000000

7087.4445534

6.0000000

7087.0565503

8.0000000

7086.6424014

10.0000000

 

Note: The StringArray object also has a StringArray.WriteToFile method, which writes the elements of a StringArray to a file. Each element becomes a new line in the file.

 

Example 2: The FileInterface Object

The FileInterface object has many options that provide the ability to read and write ASCII and binary files. The image below shows an example of the FileInterface object editor, which allows the user to configure a FileInterface's filename, read/write modes, format flags, and other properties.

 

FileInterface Object Editor

FileInterface Object Editor

 

In this example, additional acceleration data is retrieved from a randomly formatted external file called "UnmodAccel.txt", and this data is assigned to a Spacecraft ForceModel's "Other Accelerations" properties.

 

Input File: UnmodAccel.txt

 

 

Mission Plan

 

 

Output Report

 

Spacecraft1_ForceModel.OtherAccelerations[0]

0.1

Spacecraft1_ForceModel.OtherAccelerations[1]

0.12

Spacecraft1_ForceModel.OtherAccelerations[2]

0

Spacecraft1_ForceModel.OtherAccelerationsRate[0]

0.01

Spacecraft1_ForceModel.OtherAccelerationsRate[1]

0.02

Spacecraft1_ForceModel.OtherAccelerationsRate[2]

0

 

 

See Also


StringArray Properties and Methods

FileInterface Properties and Methods

FileSystem Properties and Methods

StringTokenizer Properties and Methods

Parsing Arbitrary String Data

JSON-Formatted Data