countif equivalent

Hi;
I'm just transforming to Igor from Excel. It's super faster, even if learning curve is steep. ;-)

I need to calculate how many times certain value appears in the wave. Or more specifically, how many values within certain range there are in the wave.
So I'm looking for an equivalent of excel countif option.

Example: wave that looks like this:
1
2
3
4
5
6
7

And I need to know how many values there are from the range 2
Thank you for all help!
Kate
Function CountInRange(w, minval, maxval)
    Wave w
    Variable minval, maxval // values including or between these values are counted.
   
   
    Extract/FREE/O w, extracted, w >= minval && w <= maxval
   
    Variable num= numpnts(extracted)
   
    return num
End

Example:
make/O data=p // that is, 128 integer values starting with 0 in the first element
print CountInRange(data, 3,9)
  7

--Jim Prouty
Software Engineer, WaveMetrics, Inc.