int = PlanetAtExtremalDistance(nDate, nSunSourceIndex, nPlanetID)
•The allowed values for nPlanetID range from n_MERCURY to n_PLUTO, and also include n_SUN and n_MOON.
•The sign of the result is positive if the planet is closest, and negative if the planet is furthest away on nDate. If the date nDate does not correspond to either case, then the function returns 0.
•The absolute value of the result is the time of the day expressed in one millionth of a day (less than 1/10th of a second).
The macro code below checks if any of the planets, including Pluto, as well as the Moon and the Sun, are closest to the Earth, or furthest from the Earth, on the date of the incoming macro token, and displays the result using the terms specific to the Sun and Moon.
for nPlanetID = n_SUN to n_PLUTO step 1
sBuffer = ''
nCurResIdx = PlanetAtExtremalDistance(n_TokenDate, 1, nPlanetID)
if nCurResIdx > 0
sBuffer = PlanetName(nPlanetID) + ' at apogee'
sBuffer = 'Earth at aphelion'
sBuffer = PlanetName(nPlanetID) + ' farthest from Earth'
if nCurResIdx < 0
sBuffer = 'Moon at perigee'
sBuffer = 'Earth at perihelion'
sBuffer = PlanetName(nPlanetID) + ' closest to Earth'
// add the time it occurs in parentheses
if Abs(nCurResIdx) > 1
sBuffer = sBuffer + FormatTime('" ("hh:nn")"', Abs(nCurResIdx), true)
Topic 177595, last updated on 18-Apr-2020