2006 IR Open Dicussion Posted August 27, 2006 Share Posted August 27, 2006 By: lionel - lionel82 expression syntax in fields 2006-04-06 01:45 I have a field that prints as a string the value of an integer from the database. The field is printed out in the detail section of my report. If this field is 0 I want to print N/A, otherwise I want to print the value. Can anyone help me with the syntax of what I need to do to achieve this? I thought a simple if else statement would work but my iReport complains when I attempt this. Any ideas? Thanks, Lionel. By: DarMe - darme RE: expression syntax in fields 2006-04-09 06:13 Shall work like you have mentioned. Please post yout code... By: lionel - lionel82 RE: expression syntax in fields 2006-04-09 22:33 I've tried a number of combinations but this is the current expression that I have. dosage is an Integer. if($F{dosage} = 0) return "N/A"; else return String.valueOf($F{dosage}; This is the output from iReport: net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: 1. Syntax error on token "(", ; expected value = (java.lang.String)(if(((java.lang.Integer)field_dosage.getValue()) = 0) ^ 2. Syntax error on token ";", delete this token return String.valueOf(((java.lang.Integer)field_dosage.getValue());); ^ 3. Syntax error on token "(", ; expected value = (java.lang.String)(if(((java.lang.Integer)field_dosage.getOldValue()) = 0) ^ 4. Syntax error on token ";", delete this token return String.valueOf(((java.lang.Integer)field_dosage.getOldValue());); ^ 5. Syntax error on token "(", ; expected value = (java.lang.String)(if(((java.lang.Integer)field_dosage.getValue()) = 0) ^ 6. Syntax error on token ";", delete this token return String.valueOf(((java.lang.Integer)field_dosage.getValue());); ^ 6 errors By: Nacor - nacor RE: expression syntax in fields 2006-04-10 01:21 $F{dosage}.intValue() == 0 ? "N/A" : $F{dosage}.toString() By: lionel - lionel82 RE: expression syntax in fields 2006-04-19 02:28 Great thanks. Sorry about the slow reply, I was on holiday for a week and no technology :). Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now