cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

User defined functions with examples

Former Member
0 Likes
6,463

Hi,

Being am a trainee i didnt understand much about the user-defined functions at my training period..

Will you plz tell about them with best examples as u developed in real time and their requirement in scenario..

I tried for them very much in SDN..that is not statisfactory

Regards

guna

View Entire Topic
GabrielSagaya
Active Contributor
0 Likes

User–Defined Function types:

Simple functions

*******************

1) process individual field input values for each function call.

2) expect strings as input values

3) return a string.

eg

function myudf(String a, Container container)

{

if (a.equals("Business"))

return "B";

else if (a.equals("Private"))

return "P";

else

return "X";

}

Advanced functions

**********************

1) process non–single string field input values for each function call

2) pass either all field values of a context or the whole queue

3) input field is passed as string array

4) returned values are stored in a string array, ResultList

function myudf(String a[], ResultList result, Container container)

{

for(int i=0;i<a.length;i++)

if(!a[<i>].equals(""))

result.addValues(a<i>);

}

=> This is to add non empty values to target structure.