|Top Previous Next|
Lists are a container for one or more FreeFlyer objects of the same type. The following examples show how to create, edit, and view output for various types of Lists. Keep in mind that only a selection of the possible types of Object List is shown here.
For information on collections of objects of different types, see the Structs page.
Creating a List
Lists of objects can only be created in FreeFlyer script - they can't be created in the Object Browser. Angle brackets are used to specify the type of object List you are creating. The syntax for creating a List is:
To create Lists, use the following examples as a guide:
Setting the Length of a List
When you first create a List, it will be empty. To begin editing a List, start by setting its "Count", or length. This specifies how many elements the List will contain.
Note that a List's count can also be set during its initial creation, as shown below:
The number of elements in a List can be increased or decreased at any time by changing the value of the List.Count. You can also use the List.Clear() method to reset the List back to empty. To remove individual elements from a List, use the List.RemoveAt() method, as shown below:
Note: When you remove elements from a List, the removed objects will continue to exist in memory if there were any other references to those objects. The object will be removed from the List, but the object will only be cleared completely from memory if the List was the only thing that held a reference to that object. References can be created in various ways, such as by the using reference assignment operator (:=), or by displaying the object in output views (e.g. the View command). References are also held when you use methods with state - you can call the ResetMethodStates() method on the object before clearing it from the List to remove those references. References are also held when you use the Save command; those references can be released by calling Object.ClearSavedStates().
Editing a List
Once the Count is set, you can edit the properties of the individual List elements. You can do this individually for each element, or use a For loop to set properties for all elements at once.
By including the indexing variable "i" in the expression for RAAN (Right Ascension of the Ascending Node), the GPS example above produces the following values:
You can also use reference assignment (the := operator) to configure an object contained within a List to refer to another object that you created separately. This will cause any references to that List element to refer to the specified object. The example below demonstrates using reference assignment with a GroundStation contained in a List:
Setting the Propagator and Propagating and Maneuvering Lists of Spacecraft
When working with Lists of Spacecraft, please see the following sections of the Formations article:
Output and Visualization
Since Lists can only be created and edited in FreeFlyer Script, any visualization commands or objects must be configured in script as well. The following example shows how to create simple 2D and 3D views of a List of GroundStations and a List of Spacecraft using the View and Map commands:
You can also add a List of viewable objects into a ViewWindow using the ViewWindow.AddObject() method:
3D View showing a 3-element List of GroundStations and a 6-element List of Spacecraft