Unfamiliar Syntax in Function Call Parameters

Looking through the Append Calibrator procedure file, I came across the snippet as the first line that is passed to the function in the second line.

WMNewCalibrator(graphName, xAxis, yAxis, xBar ? xLength : 0, yBar ? yLength : 0, ...)

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


So, what does this form of input parameter format do, and where is that documented?
I guess you're looking at AppendCalibrator.ipf in :IgorPro Folder:WaveMetrics Procedures:Annotations: (I couldn't find the variable 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
Apologies. I understand the ? : syntax when used as below ...

p = p == 35 ? p : 0


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?

Function MyCount(x)
   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
The expression is evaluated before calling the function.

Think of the following:
Function foo(aNum)
  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.
aclight wrote:
The expression is evaluated before calling the function.

...

The ternary operator behaves in a similar way.


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!

Function TF(aNum)
   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