"NaN" not recognized in condition statement

Dear all,

I have an experimental setup with 15 slots and I am trying to have Igor find out how many samples the user has entered by reading out the appropriate values from the result wave, "Nan" would represents a slot that the user did not use.

However, the if-construct does not correctly recognize whether there is data or not:

//Count occupied slots by counting filled rows in conc_xaxis
Function count_occupied_slots()
Variable check,x, samplecounter=0
    for(x=0;x<15;x+=1)
        check = conc_xaxis [x]
        if(check == Nan)  
            print "There is no sample in slot "+num2str(x+1)
        else
            samplecounter=samplecounter+1
        endif
    endfor
    print "Samplecounter report: There are "+num2str(samplecounter)+" used slots in current experiment."
End

The sample counter ALWAYS returns 15. Which is wrong, when the wave contains rows with "NaN" (empty slots) - where is the bug?

Thanks in advance,

regards,

Peter
You can't programmatically compare a number with NaN per definition. Use the numtype(num) function instead.