Re: Getting generic routine to call function. [message #1413] |
Fri, 19 November 1993 07:13  |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
black@signal.dra.hmg.gb (John Black) writes:
> Ooops, Sorry managed to somehow post a zero length message
> OK that message again.
> Here's the situation. I have a generic numerical routine such as a numerical
> integration routine, or a Newton-Raphson routine. Ideally I'd like to write
> them so that they can operate on any routine that evaluates a function.
> However IDL/WAVE doesn't seem to allow you to pass the name of the routine
> that evaluates a function into the generic routine, so that the generic
> routine can use it. This situation is obviously best if it can be achieved,
> because it means that you don't have to have multiple copies of the generic
> routine all caled something different, but only differ in detail in that they
> call a different function evaluating routine
> So has anyone come up with a way to do this or a way to structure code to
> get around this problem?
> Thanks in advance,
Yeah, that's easy. :^) Simply pass the name of the function as a character
string to the routine and then use EXECUTE to evaluate the function. Here are
the relevant lines from one of my own routines that uses this technique:
PRO LSTSQR,X,Y,FNAME,PARAM,PERR
.
.
.
TEST = EXECUTE('F = ' + FNAME + '(X,PARAM,FDER)')
.
.
.
Bill Thompson
|
|
|