Hi, and thank you all!

Yes, the example is far from reallity in one sense, but your example
really did the trick and conceptually it's the same!

So, for the interessted reader, I will provide my code here. (I have a
similar method for setting values.) Via an Ole32 server i communicate
with a sw that can extract all types of data from a odd type of
database.

(My final dilemma is how to get the value of STUB_CALLS into
Templates.rb by defining it in my test program Impl.rb. To define it
direcrly in the template file in not very nice... And of cause I don't
want to have to define it at all when running in non-test-mode.)

______Templates.rb______
STUB_CALLS = 1; # If this is '1', all instruments are stubed for
debugging purpouse

def GET_VALUE(f_name, method, return_format, no_of_params)
# Make a parameter list and an argument list
  if 0<no_of_params
    arg_list = 'x1';
    params = 'x1.to_s';
    for i in 2..no_of_params do
      arg_list = arg_list + ', x' + i.to_s;
      params = params + ' + \', \' + x' + i.to_s + '.to_s';
    end
    params = params+';';
  else
    arg_list = '';
    params = 0;
  end

  if (0==STUB_CALLS)
    class <<self;self;end.class_eval "def #{f_name}(#{arg_list});
      handle = OA.instance.getWIN32OLEHandle();
      params = #{params};
      handle.call(['MethodNameIn','Params'],[#{method},params]);
      ret_val = handle.GetControlValue(#{return_format});
      error = handle.GetControlValue('error out');
      if OA.instance.checkForError(error);
        return 'NaN';
      else;
        return ret_val;
      end;
    end"
  else
    class <<self;self;end.class_eval "def #{f_name}(#{arg_list});
      params = #{params};
      puts('Calling #{method}(#{arg_list}) with parameters <' + params
+ '>');
    end"
  end
end



______Templates.rb______   <- this is just three out of many
methods...
require '.\Difinitions.rb'
#***ParamsList  ["database"]
GET_VALUE('customer_getFrequency', 'getcustomerfreq', 'ResultDbl', 1)

#***ParamsList  ["database"]
GET_VALUE('customer_getSpend_thr', 'getcustspend', 'ResultDbl', 1)

#***ParamsList  ["database", "start", "stop", "inc"]
GET_VALUE('shop_GetFundReq', 'getfundreq', 'ResultDbl', 4)



______Impl.rb______ <- The implementation does already exist, and it's
huge. This is just a few lines from my test program:
require '.\Difinitions.rb'
f = customer_getFrequency(cdb)
s = customer_getSpend_thr(cdb)
fr = shop_GetFundReq(sdb, 20110101, 20110201, 'all')