Content

If function can be used in the formula

That's it, that's the most wanted feature. We get it. Conditions and logical operators are required for many calculators. And now you can build them. If function is ready!


Let's go right to the meat. If function works exactly like you are used to from Spreadsheet programs like MS Excel. Here is definition:

if(CONDITION, TRUE, ELSE)

The if function needs a CONDITION. For example 3 > 4 (3 is bigger than 4). If the condition is true, then the if function returns whatever you add to the TRUE part of the function. If the condition is false, then the if function returns whatever you add to the ELSE part of the function. Here is a simple example:

if(3 > 4, 10, 20)

This example says: If 3 is bigger than 4, return 10 else return 20. And because 3 is less than 4, this example returns the number in ELSE part which is 20. But this example is quite dump, because it will always return the same thing. We could easily just type directly 20 instead of this function. The if function gets much more interesting when you use field variables. Here is the example with a variable:

if(F123 > 4, 10, 20)

Now, we cannot easily say what the function returns, right? It depends on the value in the field with id F123. So if the value of F123 is bigger than 4, the function will return 10. If the value is less than 4, it will return 20. You can do even more advanced stuff with if function:

if(F123 > 4 and F124 != F125, F127, 0) * 3 / F126

That is quite complicated, but if your calculator requires it, you can do it. Here is what it says: If the value of F123 is bigger than 4 and value of F124 is not equal to value of F125, return value of F127 else return 0. And whatever this if function returns, multiply it by 3 and divide it by value of F126. Do you think that's the most complicated example we can think of? It still can get worse. You can combine multiple if or any other available functions into one another:

if(F123 > if(F128 == 10, F128, -1) and F124 != F125, F127, 0) * 3 / sin(F126)

I'll rather let you absorb that one alone.

Additional information