MapBasic Code. Copy/Paste if needed.
include "GC_Constants.def"
include "GC_Distance.def"

'======================================================================
function GreatCircleDistance (
   byval fLon0 as float,     'Origin longitude
   byval fLat0 as float,     'Origin latitude
   byval fLon1 as float,     'Destination longitude
   byval fLat1 as float,     'Destination latitude
   byval fRadius as float)   'Radius of sphere
   as float                  'Distance (in radius units)

'Returns the great circle distance between two points. Distance units
'are the same as those of the radius. This is equivalent to MapInfo's
'Distance() function.
'----------------------------------------------------------------------
dim a, b, c as float
dim lat0, lon0, Lat1, Lon1 as float

   lat0 = fLat0 * DEG2RAD
   lon0 = fLon0 * DEG2RAD
   lat1 = fLat1 * DEG2RAD
   lon1 = fLon1 * DEG2RAD

   a = (sin((lat1-lat0)/2))^2
   b = (sin((lon1-lon0)/2))^2

   c = (a + cos(lat1) * cos(lat0) * b)^0.5
   c = 2 * asin(c)

   GreatCircleDistance = c * fRadius
end function