Jump to content

behavior of built-in IF method in report expressions


gerald.meachem

Recommended Posts

I have noticed that he built in IF method seems to evaluate both sides of the condition even if it will not be using that particular portion.  I am wondering if this is expected behavior?  

For example:  I have an expression

 IF(FIND("n", $F{CHAR12}) > 0, MID($F{CHAR12}, FIND("n", $F{CHAR12})), "")

If there is a carriage return in the string, use the portion of the string after the carriage return.  What I get at runtime if there is no line feed in the string is an exception error

...Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
 
This leads me to believe that it is evaluating both sides of the condition and then using one or the other depending on the logical value which obviously doesn't work the way I need it to in this case.
Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...