Shouldn't this throw an error?
ChrLie
make/O/T/N=(1,2) M_Param
SetDimLabel 1,0,sVARIABLE, M_Param
SetDimLabel 1,1,numVARIABLE, M_Param
M_Param[0][%numVariable] = num2Str(99)
M_Param[0][%sVariable] = "OFF"
Edit M_Param.ld
SetDimLabel 1,0,sVARIABLE, M_Param
SetDimLabel 1,1,numVARIABLE, M_Param
M_Param[0][%numVariable] = num2Str(99)
M_Param[0][%sVariable] = "OFF"
Edit M_Param.ld
What I wanted to do was:
function ReadParam(w)
wave/T w
variable var = str2num(w[0][%numVARIABLE])
print var
// do something with var
end
wave/T w
variable var = str2num(w[0][%numVARIABLE])
print var
// do something with var
end
But what I did was
function ReadParam(w)
wave w
variable var = w[0][%numVARIABLE]
print var
// do something with var
end
wave w
variable var = w[0][%numVARIABLE]
print var
// do something with var
end
This executed without problem, but gave wrong results. Ok, w is incorrectly declared to be numeric, but shouldn't the assignment of var fail?
And igor knows that it is a text wave
wave w
// prints 2 for text waves
print WaveType(w,1)
end
December 9, 2013 at 09:50 am - Permalink
I suppose you could argue that there should be a run-time check. I think we tend to leave out such checks because they can slow down critical operations. You can add the check, of course, but if the problem is caused by an error it's hard to see why you would add the check!
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
December 9, 2013 at 10:19 am - Permalink
Maybe a future rtGlobals=4 could force the user to say either "Wave/D" or "Wave/T" in order to make it clearer what is expected as wave type. Or maybe introduce a new wave flag which says numeric type.
I would be the first user for rtglobals=4 :)
December 10, 2013 at 03:51 am - Permalink