; find_spin (interactive)
;
; permits click on the data-set, and high-light the closer
; spin in the db
;

point_clear
monopoint
set f1 = (itop($pointy[1],2,1))  set f2 = (itop($pointx[1],2,2))

set found = 0
find spin 1 $f1

if ($pk_fnd_dst < $tol_click ) then
  set ss = $scolor
  if ($scolor <6) then
    scolor (%+1)
  else
    scolor 1
  endif
  show_spin $pk_fnd
  scolor $ss
  set last_click := ("SPIN"; $pk_fnd)
  print $last_click
  set found = (%+1)
endif

find spin 1 $f2
if ($pk_fnd_dst < $tol_click ) then
  set ss = $scolor
  if ($scolor <6) then
    scolor (%+1)
  else
    scolor 1
  endif
  show_spin $pk_fnd
  scolor $ss
  set last_click := ("SPIN"; $pk_fnd)
  print $last_click
  set found = (%+1)
endif

if ($found == 0) then
   alert ("No spin found within"; $tol_click; "ppm")
   set returned := 0
else
   set returned := $pk_fnd
endif


