jrebelo
27th May 2015, 17:52
In ERP Baan I use the following script in VB.net to call any DLL.
BaanObj = CreateObject("Baan4.Application ")
BaanObj.ParseExecFunction("oteprgdll0001nn", "function.test(" & var_input & "," & var_output & ")")
Return BaanObj.FunctionCall
In addition to calling the DLL it was also possible to get the return of the variables.
In ERP LN I can call the DLL but I can’t get the return of the variables.
BaanObj = CreateObject("Baan.Application.InforERPLn")
BaanObj.ParseExecFunction("oteprgdll0001nn", "function.test(" & var_input & "," & var_output & ")")
Return BaanObj.FunctionCall
The DDL I call is:
function extern function.test(
long var.input,
ref long var.output
)
{
var.output = var.input + 11
}
In Baan4 when I put the function name like "function.test(15,0)" in the object "BaanObj.ParseExecFunction".
I get the string "function.test(15,26)" in the object "Return BaanObj.FunctionCall"
In LN I do the same but the return of the object Return BaanObj.FunctionCall" is the same when i call the DLL.
Is there any way to get that with LN in VB script?
Thanks in advance
benito
27th May 2015, 22:48
should you write function extern LONG function.test( blah, blah...?
jrebelo
28th May 2015, 11:47
Benito, that doesn't work. I can get the return value if return something from the function with the VB code "BaanObj.ReturnValue" but I can't get the change of the output variable.
In Baan4 I get the change of the output variable with the VB code "BaanObj.FunctionCall". In LN that doesn't work.
I have been talking with many people but no one knows how to solve that.
Thanks for the answer Benito.
bhushanchanda
28th May 2015, 12:55
Hi,
Try this -
Say your DLL name in LN is tdslsdlltest which has a function named some_function
function extern long some_function(long x)
{
long y
y = x + 23
return(y)
}
Now,
Here's the VB Script. BaanObj.ReturnValue function is used to get the return values.
Set BaanObj = CreateObject("Baan.Application.Test")
var_input = 6
BaanObj.ParseExecFunction "otdslsdlltest" ,"some_function(" & var_input & ")"
var_output = BaanObj.ReturnValue
msgbox(var_output)
jrebelo
28th May 2015, 14:02
Hi bhushanchanda,
Yes, that is a way, but most of the DLL's I work with return more than 1 variable with diferent domains.
What I really need is obtain the variables that are an output from the DLL like I was calling it in LN.
Thanks for the answer bhushanchanda.
bhushanchanda
28th May 2015, 15:01
Hi,
I do not think, without a return domain for a function, the function will return anything to the VB Script.
e.g. function extern domain_name function_name()
Here, domain name is required to get some value to the VB Script.
Now, if you want to return multiple things from a single function in a DLL, what I would suggest is, concatenate all the values in a string and return that string to VB DLL. Now, you can split it and use it in whatever way you want.
Sometimes, you just need to find a way.
e.g
The VB Code -
Set BaanObj = CreateObject("Baan.Application.test")
creg = "TTN"
var_input = 6
BaanObj.ParseExecFunction "otdslsdlltest" ,"some_function(" & var_input & ")"
var_output = BaanObj.ReturnValue
msgbox(var_output)
The LN code -
function extern domain tcmcs.str100 some_function(long x)
{
long y
string z(10)
y = x + 29
if y > 40 then
z = "Good"
else
z = "Bad"
endif
return(str$(y)&z)
}
jrebelo
28th May 2015, 16:10
bhushanchanda, in Baan4 it works.
In Baan4 when I put the function name like "function.test(15,0)" in the object "BaanObj.ParseExecFunction".
I get the string "function.test(15,26)" in the object "Return BaanObj.FunctionCall".
But when I do the same in LN it does't work.
The problem is that I have a apllication in .Net at Baan4, and I will migrate to LN. If can't do the same connection in LN, I have to change all the structure of DLL's.
And that is a lot of work!
Thanks for the answer bhushanchanda.
bhushanchanda
28th May 2015, 17:30
So,
I guess, you were using a wrong function. FunctionCall will always return the function which was called. The right thing to use was ReturnCall.
So, here it goes -
LN Code -
function extern some_function(long x,ref long y)
{
y = x + 29
}
VB Code -
Option Explicit
Dim BaanObj
Set BaanObj = CreateObject("Baan.Application.test")
Dim var_input: var_input = 10
Dim var_output: var_output = 0
Dim var_outputfinal
BaanObj.ParseExecFunction "otdslsdlltest" ,"some_function(" & var_input & "," & var_output & ")"
var_outputfinal = BaanObj.ReturnCall
msgbox(var_outputfinal)
Hope it helps.
jrebelo
28th May 2015, 17:37
It Works!
Thanks a lot bhushanchanda! :)