evesely
23rd October 2002, 19:17
Is there a nice way to write a generic function that calls other functions in the same program script based upon a string that is passed? This would be similar to the way in which on.old.occ(function) works.

For example, I have a wrapper function (let's call it wrapper()) that takes a string value. It does some processing and then calls the function indicated by the string. Let's say I have functions a(), b(), and c(). I would like to be able to call wrapper("a") and have the wrapper function launch function a().

I have thought about the load_dll, exec_function, ... functions, but I don't know if they are appropriate here since I am working within only one program script.

Thoughts?

~Vamsi
23rd October 2002, 20:37
function main()
{
#define MYFUNC(a) a()
MYFUNC(a)
MYFUNC(b)
}

function a()
{
message("hello a")
}

function b()
{
message("hello b")
}

~Vamsi
23rd October 2002, 20:49
function main()
{
#define MYFUNC(a,...) a(...)
MYFUNC(a)
MYFUNC(b, 10)
}

function a()
{
message("hello a")
}

function b(long longvar)
{
message("hello b %d", longvar)
}

evesely
23rd October 2002, 20:54
I thought about that, but I don't think it will work in my case. Here is what I want to do:


field.x:
check.input:
wrapper("a")

field.y:
check.input:
wrapper("b")
...
function wrapper(string func)
{
...
<call to function func; e.g., a() or b()>
...
}


If I try to use func in the macro, it would give me a syntax error.

Any other thoughts?

NPRao
23rd October 2002, 21:16
check out -

http://www.baanboard.com/programmers_manual_baanerp_help_functions_dll_load_dll

and

http://www.baanboard.com/programmers_manual_baanerp_help_functions_dll_parse_and_exec_function