User defined Function within if function

Hello,

is it possible to use a user defined function nested within a if function? I have an expression like:

<#if(TRUE(evaluate(CompressionEnabled));"active compression"; inactive compression)>

where CompressionEnabled is a user defined function returning a boolean result. But I get an error message stating that CompressionEnabled is not defined. I also tried it without the evaluate function but i still get the error.

When I use this function without the if function it is working. I'm using FlexCel version 6.18.0.0 .


Best Regards,

Christian Sack

Hi,

I am not sure on where you define CompressionEnabled, but shouldn't it be <#CompressionEnabled> ?

I think you could define the expression like this:
<#if(<#CompressionEnabled>;"active compression"; "inactive compression")>

If compressionenabled is a function, not an expression or a value, then it would be:
<#if(<#CompressionEnabled()>;"active compression"; "inactive compression")>

But it is likely the first option

Thanks for your help. It works with your provided example. I thought within the if function a user defined function is called like an existing Excel function. But thanks to pointing out the right way.


Best Regards,

Christian Sack

Maybe there is a confusion between "Excel user defined functions" and "FlexCel user defined functions". I know it isn't too cleat, but FlexCel user defined functions were implemented long before Excel user defined functions (like 10 years before), so in many places they are just referred as "user defined functions" and it might not be clear to which one we are referring to.


In short:
A FlexCel user defined function is used in reports, and they use the same <#tag> notation as every other tag.
An Excel user defined function is a function Excel can use and you define in a macro. Excel user defined functions indeed are called as normal Excel functions inside the <#if>, because they work as normal Excel functions.