0 Replies Latest reply: Dec 14, 2011 8:24 PM by gregg111 RSS

    Nested user defined function

      Hi

      I'm creating a user defined function as below:

       

      SET GetUSDRate =

      if((not IsNull($1)) and (len($1) > 0) and (IsNum($1)) and ($1 <> 0),$1,if((not IsNull($2)) and (len($2) > 0) and (IsNum($2)) and ($2 <> 0),$2,$3));

       

      Basically I pass in 3 rates and it returns the first non-null non-zero rate it finds.  What I want to do is make one of the parameters I pass in the result of a different function.

       

      So my call looks something like:

       

      $(GetUSDRate(0,[Override USD Rate],[FX Currency USD Rate]))

       

      What I want to know is how can I replace the first parameter of zero with the result of a function, for example:

       

      $(GetUSDRate( $(NewFunction(param1)),[Override USD Rate],[FX Currency USD Rate]))

       

      I've tried something like above but it doesn't work.  I can't use variables as this is a set based operation and the result of "NewFunction" is based on data specific to each row.

       

      I'm new to QV so I might be going about this completely the wrong way.

       

      Hope this makes sense.  Any help appreciated.

       

      Thanks

      Gregg.