on 08-02-2006 9:57 PM
Hi
I want to code a UDF which comapres an array that contains "X" or empty values,with an array which contains only "X" and return a boolean array with boolean arguments (true/false)
I tried using the exisiting functions but I didnt find something relevant
Thx,Shai
Shai,
you don't need an "array" of 'X'. You only need one constant with the value 'X'. The text function equalS will continue to compare the values provided by your array with the constant 'X' and create an output array of true/false accordingly.
Regards,
Claus
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As the guys have said, you won't get an boolean array from an UDF.
The best you could get from an UFD is a string where each char is either 1 or 0, meaning true or false. Your input could also be a string with either X's or whitespaces.
You could do it like:
int i = 0;
String output = "";
while (i < input.length()) {
if (input.charAt(i) == 'X') {
output = output.concat("1");
}
else {
output = output.concat("0");
}
i++;
}
return output;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
<i> return a boolean array with boolean arguments (true/false)</i>
AFAIK, an User Defined Function can return only a STRING. It cannot return a Boolean Variable and also cannot return an Array.
Regards,
Bhavesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Func 1: public void ChkForX(String[] a,ResultList result,Container container){
int flag = 0;
int count = 0;
for (int i = 0; i<a.length; i++)
{
if(a<i>equals("X"))
{flag = 0; }
else
{flag = 1;
count = count + 1;
}
}
if(count > 0)
{
result.addValue("1");
}
else
{result.addValue("0");
}
Func 2:
public void ChkSpaces(String[] a,ResultList result,Container container){
int flag = 0;
int count = 0;
for (int i = 0; i<a.length; i++)
{
if(a<i>equals(" "))
{flag = 0; }
else
{flag = 1;
count = count + 1;
}
}
if(count > 0)
{
result.addValue("2");
}
else
{result.addValue("3");
}
Kinda use both these functions with the same input then further build your logic ... but still i dont think you will get a array as output using UDF
Hi Shai,
if I understand your scenario correct you can do that easily with the existing functions. Just use
Array
equalS --> Result
Constant[X] /
Array is the list that contains your input values (X or empty), Result is your target value that will contain true or false. The function equalS will continue to compare the value of Array with the constant X.
Regards,
Claus
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.