cancel
Showing results for 
Search instead for 
Did you mean: 

UDF help

Former Member
0 Kudos

Dear All,

Kindly let me know what am I doing wrong in the below code? I am getting errors in the UDF ...


int I_Length = 0;
int H_Count = 0;

String flag;

H_Count = I_Val.replaceAll("-","").length();  // Count all "-" in the string
I_Length = I_Val.length();                              // Count the length of the string

if ( (H_Count.equals("3")) && (I_Length.equals("21")) )
	flag = "x";
else flag = "y";

return flag;

"I_Val" is a variable that I am passing in the UDF. I getting error as - Error in source code.

Please help. Thanks,

--Abhi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Adding to my initial question, I noticed that the problem comes in the "if" statement as it gives error message for "de-referencing" where I check for equals() ...

When I make the "int" as "string", although even the true condition fails, but there is no error message ...

I know equals() returns a Boolean true or false, but I am surprised how this equality is not working !!

Any suggestions? Thanks.

MichalKrawczyk
Active Contributor
0 Kudos

hi,

did you try the line change as per my suggestion ?

Regards,

Michal Krawczyk

Former Member
0 Kudos

Yes Michal ... it worked !! Thanks for your kind help. You are extra cool

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

>>>Yes Michal ... it worked !! Thanks for your kind help.

no problem

>>> You are extra cool

I know hehe

Thanks Abhi,

Regards,

Michal Krawczyk

Answers (1)

Answers (1)

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

can you try replacing this :

if ( (H_Count.equals("3")) && (I_Length.equals("21")) )

with this:

if ( H_Count == 3 && I_Length == 21 )

Regards,

Michal Krawczyk