; 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 ss = $scolor

; first in F1
foreach sp in spin within 1 ($f1-$tol_align) ($f1+$tol_align)
    if ($scolor <6) then
      scolor (%+1)
    else
      scolor 1
    endif
    show_spin $sp
    scolor $ss
    comp_spin_label $sp
    if (exist('found')) then
       set found = (% // ',' // $sp ; '(F1:' // $returned // ')' )
    else
       set found = ($sp ; '(F1:' // $returned // ')' )
    endif
endfor

foreach sp in spin within 1 ($f2-$tol_align) ($f2+$tol_align)
    if ($scolor <6) then
      scolor (%+1)
    else
      scolor 1
    endif
    show_spin $sp
    scolor $ss
    if (exist('found')) then
       set found = (% // ',' // $sp ; '(F2:' // $returned // ')' )
    else
       set found = ($sp ; '(F2:' // $returned // ')' )
    endif
endfor


if ($found s= ' ') then
   alert ("No spin found within"; $tol_click; "ppm")
   set returned := 0
else
   dialogbox 'Choose spin' \
      'Select the Spin you want to define' enum $found sp % *
   set returned := (head($sp))
   set last_click = ('SPIN'; (head($sp)))
endif


