PlateStars Collection
Set stars = p.ImageStars ' Create the collection once!
For i = 1 To stars.Count ' Index starts at 1 not 0
Print stars(i).X
Next
In the above example, p is a Plate object, and stars(i) returns a PlateStar object representing the i-th star in the ImageStars list. This may sound complex now, but once you use it it will seem very natural. One thisng to note in the above example: the collection is first explicitly created, then used in the loop. If you don't do this, you'll be recreating the collection for each iteration of the loop -- very inefficient.
Some languages (e.g., Visual Basic) support intrinsic enumeration. In Visual Basic, you can write:
For Each star In p.ImageStars
Print star.X
Next
This should seem really natural to you. JScript (aka JavaScript or ECMAScript) has its own way of enumerating using an Enumerator object created from the collection:
stars = new Enumerator(p.ImageStars);
for (; !stars.atEnd(); stars.moveNext())
{
Console.PrintLine(stars.item().x);
}
In the above examples, the collection is used directoy in the For-Each statement or in the Enumerator constructor. If you want to sort the collection, you must first create it explicitly, assigning it to a variable, then sort it, then do the For-Each statemtne, etc. For example, in JScript:
col = p.ImageStars;
col.Sort(3, 0, refRA, refDec);
stars = new Enumerator(col);
for (; !stars.atEnd(); stars.moveNext())
{
Console.PrintLine(stars.item().RightAscension);
}