I need a user define function which is similar to excel function named AGGREGATE function (), which allow me to adjust which functions to use.

The user defines function should look like, UDF (lookup_vector, result_vector, operator, process_1, figure_1, process_2, figure_2)

The UDF will calculate
1st step :( process_1, figure_1) then
2nd step :( process_2, figure_2) then
3rd step: process 1st step and 2nd step with (operator)

The conditions for the UDF is below,
If (process_1) =0, (figure_1) will be any number entry by user
If (process_1) =1, UDF perform log10 function on (figure_1)
If (process_1) =2, (figure_1) will be a lookup value, and UDF perform log10 function on the result of the lookup.
***Apply the same for (process_2, figure_2)

If (operator) =0, (figure_1) + (figure_2)
If (operator) =1, (figure_1) - (figure_2)

Example,
Assume $A$1:$B$1 is lookup vector with number 1, 2.
And $A$2:$B$2 is result vector with number 10, 20.

UDF ($A$1:$B$1,$A$2:$B$2,0,0,44,0,44)= 44 + 44 =88
UDF ($A$1:$B$1,$A$2:$B$2,0,1,44,1,44)=log10(44) + log10(44)= 3.286
UDF ($A$1:$B$1,$A$2:$B2,1,2,1,0,44)=log10(10) - 44= -43