Unfamiliar Syntax in Function Call Parameters
jjweimer
WMNewCalibrator(graphName, xAxis, yAxis, xBar ? xLength : 0, yBar ? yLength : 0, ...)
Function WMNewCalibrator(graphName, xaxis, yaxis, dx, dy, ...)
Function WMNewCalibrator(graphName, xaxis, yaxis, dx, dy, ...)
I _think_ I know what the " ? :" parameter input syntax might do (an implicit logic test), but tracking the lines through the remaining code in the Function left me rather confused. I was expecting perhaps the explicit equivalent of ...
Function WMNewCalibrator(graphName, xaxis, yaxis, dx, dy, ...)
variable ... dx
variable idx = 0
idx = idx == dx
variable ... dx
variable idx = 0
idx = idx == dx
So, what does this form of input parameter format do, and where is that documented?
DisplayHelpTopic "? :"
March 3, 2011 at 12:35 pm - Permalink
AppendCalibrator.ipf
in:IgorPro Folder:WaveMetrics Procedures:Annotations:
(I couldn't find thevariable idx = 0
statement in version 6.1 of that file).I don't exactly understand your question --- is it about the conditional operator
? :
?--- or about something else in these particular functions ?
The conditional operator is documented in
IgorReference.ihf
(DisplayHelpTopic "? :"
). It is just used in the call here and does not represent a new mysterious "input parameter syntax". [EDIT: aclight was of course faster!]Wolfgang
March 3, 2011 at 12:48 pm - Permalink
What I do not understand is how this syntax can be passed in a parameter call to a function. How is it interpreted within the function? What is the proper format to handle such an input?
variable x
variable y
y = 3 == x
return y
end
MyCount(35 ? 24 : 4)
I did not see this format in the calibrator code (perhaps I overlooked it).
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
March 3, 2011 at 01:09 pm - Permalink
Think of the following:
Variable aNum
...
End
foo(2+2)
When the foo() function executes, it gets aNum=4 as its parameter.
The ternary operator behaves in a similar way.
March 3, 2011 at 01:50 pm - Permalink
I'm still a bit confused -- seems like I am at a transistor point (the operation of any electronic component with more than three legs is typically a mystery to me)
( ... plays a bit at Igor ...)
OH! So this can work too!
variable aNum
return aNum
end
variable x = 1, y = 2
print TF(x > y ? 1 : 0 ) --> 0
print TF(y > x ? 1 : 0 ) --> 1
I'll have to look at the code a bit. It seems however the shorter syntax foo(dx ? dx : 35) passes 35 to foo anytime dx is zero before entering foo, otherwise dx is passed to foo. So it functions as a selective (notch) filter.
Thanks!
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
March 3, 2011 at 02:40 pm - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
March 8, 2011 at 05:07 pm - Permalink