OmeLuuk
14th February 2019, 18:37
This is a somewhat out-of-the-box question.

Usually in a program script you can call functions in a DLL by just typing their name: tccomdllo0001.do.check.this.bp(tccom001.bpid)

What I want to try is this:
In a fixed program (once compiled) I want to be able to extend its functionality and call newer DLL functions without touching the caller program.

I think it is impossible, since you need this "function call" in the object "used functions". On the other hand, is the PCF not more or less doing the same?

So I want to put the name of the function to be called from a (set of) DLLs
(which are declared = #pragma used dll "ofunction_library") in a variable.
Like in
if pos(filename, VAR_FILETYPE_1) <> 0 and
tccomdll.&FUNCTION_FILETYPE_1(FUNC_ARG_LIST_1) then
mess("tcgenstring", 1, "File " & filename & " passed test " & FUNCTION_FILETYPE_1)

In this way you can call any pre-programmed function for any file-type depending on the content of the program string variables VAR_FILETYPE_1, FUNCTION_FILETYPE_1 and FUNC_ARG_LIST_1.

It is a bit similar to what you can do with program variables
if put.var(pid, trim$(tolower$(tccom905.pvid)), trim$(
tccom905.data)) =1 then
message("Program Variable " & quoted.string(
trim$(tolower$(tccom905.pvid))) &
" set to value " & trim$(tccom905.data) & ".")
endif
It is a bit similar to var_1 = trim$(tccom905.data) except that also the name of the variable is variable... to a certain extend (as is its datatype due to implicit conversion).

The named program variable in tccom905.pvid must be pre-known in the program script and declared extern, but its value and its name can be set in a parameterized table tccom905.

Your first question would be: why would you want this?
hmmm you made me thinking like :confused:

It is easy to do the something similar with:
if pos(filename, VAR_FILENAME_1) <> 0 and tccomdllo0001.do.check.1(FUNC_ARG_LIST_1) then

NPRao
14th February 2019, 20:28
If I understood your question correctly, you like to call a new function in a new DLL dynamically? Yes, it is possible.

Refer to the functions in the link -

DLL functions (executing) overview and synopsis (http://www.baanboard.com/programmers_manual_baanerp_help_functions_dll_overview_and_synopsis)

Question exec_dll_function Fatel Error (http://www.baanboard.com/baanboard/showthread.php?t=60134&highlight=load_dll)

OmeLuuk
15th February 2019, 21:50
Spot on! Thanks a lot.

OmeLuuk
20th February 2019, 18:23
Current status of implementation :cool:
function init.dll.checks()
{
my.dll = load_dll("owhinhdllo9160", DLL_OVERLOAD+DLL_SILENT_ERR)
for i = 1 to MAX.SESN
get.var(pid, "sesn_" & str$(i) & "_name", s.dummy)
if not isspace(s.dummy) then
get.var(pid, "sesn_" & str$(i) & "_check", s.dummy)
a.func(i) = get_function(my.dll, s.dummy)
else
a.func(i) = 0
endif
endfor
for i = MAX.SESN + 1 to MAX.SESN + MAX.REPN
get.var(pid, "repn_" & str$(i - MAX.SESN) & "_name", s.dummy)
if not isspace(s.dummy) then
get.var(pid, "repn_" & str$(i - MAX.SESN) & "_check", s.dummy)
a.func(i) = get_function(my.dll, s.dummy)
else
a.func(i) = 0
endif
endfor
ret = exec_function(my.dll, get_function(my.dll,
"whinhdllo9160.init.vars"))
}