on 04-09-2008 10:45 AM
Hi,
We have written a user defined function with the simple 'if' condition.
But the code will not be compiled without an 'else' statement.
What if we do not want to return any values for the else condition.?
See our simple code below
if (a.equals("AG") && b.equals("Y990028") && c.equals("A3"))
return "X1";
else if (a.equals("AG") && b.equals("Y990033") && c.equals("A3"))
return "X2";
else if (a.equals("AG") && b.equals("Y990108") && c.equals("A9"))
return "X3";
It is giving an error since there is no else condition.
We do not want to generate the element for an else condition.
Please help.
Thanks,
John
Hi john,
if you don't want to return any value for else condition then you can add the line:
else
return"";
**Reward points if helpful.
--Sankar Choudhury
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In User Defined Functions the Return value is must.
If you are using the If condition then there are chances to fail the conditions so at that time none of the return statement will be executed, thus it will request to add the else condition with Return statement.
Probably you could add the below statement in else condition. It will not affect you code and will server the purpose also.
else
return();
Thanks
Swarup
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
maybe you could return a SUPPRESS value in the else condition.
Regards
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.