on 03-18-2008 12:17 PM
Hi Experts,
i have the following requirement i had done this using graphical any way i am trying to write the UDF for the same.I am unable to complete this.Can anybody guide me to complete this.
Reuirement is as :- I have two inputs as a and b and need to implement the logic as X = (((a)/((b/a)100)+100)((b/a)*100))
Thanks in Advance
Abhijit
Edited by: ABHIJIT DAPTARY on Mar 18, 2008 5:48 PM
Hi Abhijit,
If you are getting floating point numbers (ex 123.45) in a or b then try this udf:
public String calculate(String a,String b, Container container){
float aa=Float.parseFloat(a);
float bb=Float.parseFloat(b);
return String.valueOf((aa/((bb/aa)100)+100)((bb/aa)*100));
}
Regards
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 avijit,
make an UDF with two argument checking the value option and paste the following code;
int x,y,z,m,n,o,p,r;
x=Integer.parseInt(a);
y=Integer.parseInt(b);
m= y/x;
n=m*100;
r=x/n;
o=r+100;
p=o*n;
String str= new String();
str=new Integer(p).toString();
return str;
In case if the numbers are floating no then just write float instead int/Integer.
Regards,
Arijit
p.s: please reward point if useful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Abhijit,
Paste this line of code :
return String.valueOf((a/((b/a)100)+100)((b/a)*100));
Regards
Sankar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
As told my swarup you can do it by dividing it into two expressions.Here is the complete code on how to typecast the string and use it in XI.
Public void test(String a,String b){
float c=Float.parseFloat(a);
float d=Float.parseFloat(b);
float B,C,D;
B=(d/c)*100;
C=(c/B)+100;
D=C+B;
return(D+"");
}
Thanks,
Bhargav.
Note:Award points if found useful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI,
The expression X = (((a)/((b/a)100)+100)((b/a)*100))
can be split-up as two expressions
A = ((aa)/(b100))+100
&&&
B=(b/a)*100
Please find here with you the UDF code
You need to convert the a and b to float type.
float c,d;
c= Float.parseFloat(a);
d= Float.parseFloat(b);
float A, B;
A = ((cc)/(d100))+100;
B=(d/c)*100;
return(String.valueOf(A*B));
Thanks
Swarup
Edited by: Swarup Sawant on Mar 18, 2008 1:29 PM
Edited by: Swarup Sawant on Mar 18, 2008 1:51 PM
Edited by: Swarup Sawant on Mar 18, 2008 1:54 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.