subr crossmask_callback
 ;a plot and select done yet?
 if defined($crossflag2) eq 0 then {
  xmmessage,'no select yet', $f7, 'red'  return }
 ;need the image windows and the mask window
 w1 = fix(xmtextfieldgetstring ($crosstext(1))
 if window_data(w1, z1, s1, nx, ny) then return
 w2 = fix(xmtextfieldgetstring ($crosstext(2))
 w4 = fix(xmtextfieldgetstring ($crosstext(4))
 if window_data(w2, z2, s2, nx2, ny2) then return
 dump, z1, z2
 ;now, find all the points with these values

 in = sieve(z1 ge $cross_x1)
 in = sieve(in, z1(in) le $cross_x2)
 in = sieve(in, z2(in) ge $cross_y1)
 in = sieve(in, z2(in) le $cross_y2)
 ;in should now be all the indices that have values in the box
 mask = zero(bytarr(nx, ny))
 mask(in) = 1

 switch, z1, eval(s1)
 switch, z2, eval(s2)
 switch, mask, eval('$data'+istring(w4, 1))
 ;set to min/max scale here
 $view_scaletype(w4) = 1
 view, w4
 endsubr
 ;===============================================================================