on 07-16-2012 4:53 PM
Hi all,
we are working on a UDF to remove "blank or SUPPRESS lines" from context.
we found below useful code, But, it is not yet in working condition.
for (int i=0; i<a.length();i++)
{
if (!a[i].equals(ResultList.SUPPRESS) || !a[i].equals(""))
{
result.addValue(a[i]);
}
}
Can someone pls help with the steps & any changes needed on above code....
I dont know your requirement completely. But I see a error. Since you use string array , you need to use a.length not length(). Do as below..
for (int i=0; i<a.length;i++)
{
if (!a[i].equals(ResultList.SUPPRESS) || !a[i].equals(""))
{
result.addValue(a[i]);
}
}
You might also want to see Bill's reply very similar to your requirement on this thread
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you baskar.
Our requirement is to remove blank contexts from below screenshot & output only those contexts , which has values. In case of below example, am expecting output value of "GB1-IRVAT-TX" .
By changing a.length from a.length() , it is error free code now. But, still not giving desired results.
Below is the source code snapshot,
Thank you for your help....
Hi Baskar,
Your if condition,
if(a[i] != null && !a[i].equals("") && !a[i].equals(Resultset.SUPPRESS))
would go thru, only if all && conditions are met.
which is not true. Only 1 of the above conditions is true @ any given time.
I tried the above code as well. But, no results....
But, even OR condition is also not giving desired results...
for (int i=0; i<a.length;i++)
{
if (!a[i].equalsIgnoreCase(ResultList.SUPPRESS) || !a[i].equals(""))
{
result.addValue(a[i]);
}
}
Not sure, what is going wrong....
Hi,
The trim function mentioned by Lucho is the key to your requirement. Also, bear in mind that the following conditions are equivalent:
not (A or B or C)
not A and not B and not C
After all, here is the code for your requirement:
for (int i=0; i < a.length; i++) {
if (!a[i].equals(ResultList.SUPPRESS) && !a[i].trim().equals("")) {
result.addValue(a[i]);
}
}
The condition you had:
!a[i].equalsIgnoreCase(ResultList.SUPPRESS) || !a[i].equals("")
is always true, since a[i] is always either different than SUPPRESS, or different from empty .
Regards,
Greg
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.